根据未知模式匹配不匹配的字符串(Matching unmatched strings based on a unknown pattern)
好吧,我真的很伤脑筋,而且我很好奇,如果你们能给我任何指向我应该采取的正确方向的指示。
情况是这样的:
比方说,我有一个字符串集合(要明确这个字符串的模式是未知的,事实上,我可以说字符串只包含ASCII表中的符号,因此我不必担心关于奇怪的中国标志)。
在这个例子中,我将下面的字符串集合(请注意,字符串不必做任何人类感觉,所以不要试图找出它们:)):
"[001].[FOO].[TEST] - 'foofoo.test'", "[002].[FOO].[TEST] - 'foofoo.test'", "[003].[FOO].[TEST] - 'foofoo.test'", "[001].[FOO].[TEST] - 'foofoo.test.sample'", "[002].[FOO].[TEST] - 'foofoo.test.sample'", "-001- BAR.[TEST] - 'bartest.xx1", "-002- BAR.[TEST] - 'bartest.xx1"
现在,我需要的是找到这些字符串的逻辑组(和子组),所以在上面的例子中,只需通过理性思考,就可以将前3个,后2个和后2个也可以将前5个组合成一个主组和2个子组,这应该是这样的:
{ { "[001].[FOO].[TEST] - 'foofoo.test'", "[002].[FOO].[TEST] - 'foofoo.test'", "[003].[FOO].[TEST] - 'foofoo.test'", } { "[001].[FOO].[TEST] - 'foofoo.test.sample'", "[002].[FOO].[TEST] - 'foofoo.test.sample'", } } { { "-001- BAR.[TEST] - 'bartest.xx1", "-002- BAR.[TEST] - 'bartest.xx1" } }
对不起,上面的布局,但缩进4空格似乎并不正确(或我frakk'n它)。
无论如何,我不知道如何解决这个问题(如何获得如上所示的结果)。
首先,我想创建一个庞大的正则表达式来分析大多数已知的模式,但不同模式的数量是巨大的,这是不现实的。
另一个想法是我想解析一个字符串中的每个单词(所以去掉所有非字母或数字字符并按这些字符拆分),如果X%匹配,我可以假设这些字符串属于同一个组。 (其中X可能在80/90左右)。 不过,我觉得这个投机领域有点大。 例如,当匹配每20个单词的字符串时,击中80%以上的变化有点大(即4个单词可以不同),但是只匹配8个单词时,最多可以有2个单词不同。
我的问题是,在上述情况下,什么是合乎逻辑的方法?
至于再生的例子:
提前致谢!
Alright guys, I really hurt my brain over this one and I'm curious if you guys can give me any pointers towards the right direction I should be taking.
The situation is this:
Lets say, I have a collection of strings (let it be clear that the pattern of this strings is unknown. For a fact, I can say that the string contain only signs from the ASCII table and therefore, I don't have to worry about weird Chinese signs).
For this example, I take the following collection of strings (note that the strings don't have to make any human sense so don't try figuring them out :)):
"[001].[FOO].[TEST] - 'foofoo.test'", "[002].[FOO].[TEST] - 'foofoo.test'", "[003].[FOO].[TEST] - 'foofoo.test'", "[001].[FOO].[TEST] - 'foofoo.test.sample'", "[002].[FOO].[TEST] - 'foofoo.test.sample'", "-001- BAR.[TEST] - 'bartest.xx1", "-002- BAR.[TEST] - 'bartest.xx1"
Now, what I need to have is a way of finding logical groups (and subgroups) of these set of strings, so in the above example, just by rational thinking, you can combine the first 3, the 2 after that and the last 2. Also the resulting groups from the first 5 can be combined in one main group with 2 subgroups, this should give you something like this:
{ { "[001].[FOO].[TEST] - 'foofoo.test'", "[002].[FOO].[TEST] - 'foofoo.test'", "[003].[FOO].[TEST] - 'foofoo.test'", } { "[001].[FOO].[TEST] - 'foofoo.test.sample'", "[002].[FOO].[TEST] - 'foofoo.test.sample'", } } { { "-001- BAR.[TEST] - 'bartest.xx1", "-002- BAR.[TEST] - 'bartest.xx1" } }
Sorry for the layout above but indenting with 4 spaces doesn't seem to work correctly (or I'm frakk'n it up).
Anyway, I'm not sure how to approach this problem (how to get the result desired as indicated above).
First of, I thought of creating a huge set of regexes which would parse most known patterns but the amount of different patterns is just to huge that this isn't realistic.
Another think I thought of was parsing each individual word within a string (so strip all non alphabetic or numeric characters and split by those), and if X% matches, I can assume the strings belong to the same group. (where X will probably be around 80/90). However, I find the area of speculation kinda big. For example, when matching strings with each 20 words, the change of hitting above 80% is kinda big (that means that 4 words can differ), however when matching only 8 words, 2 words at most can differ.
My question to you is, what would be a logical approach in the above situation?
As for a reallife example:
Thanks in advance!
原文:https://stackoverflow.com/questions/2571226
最满意答案
您应该将tickInterval设置为24 * 3600 * 1000(以milisecods为单位)。
xAxis: { tickInterval: 24 * 3600 * 1000 }
You should set the tickInterval as 24 * 3600 * 1000 (one day in milisecods).
xAxis: { tickInterval: 24 * 3600 * 1000 }
相关问答
更多-
解决方案:仅供其他人参考。 它已经解决了。 问题是: xAxis : { tickInterval : 4 }, 在一个小的tickInterval上强制xAxis会导致所有麻烦。 Solution: Just for the information of others. it's resolved. The problem was the: xAxis : { tickInterval : 4 }, Forcing the xAxis on a small tickInterval cause ...
-
结合xAxis Highcharts(Combine xAxis Highcharts)[2019-11-14]
您可以使用tickInterval控制它: xAxis: { labels: { rotation: -33, }, tickInterval:1 }, http://codepen.io/bhlaird/pen/WoGmNd http://api.highcharts.com/highcharts/xAxis.tickInterval You can control that with tickInterval: ... -
您应该将tickInterval设置为24 * 3600 * 1000(以milisecods为单位)。 xAxis: { tickInterval: 24 * 3600 * 1000 } You should set the tickInterval as 24 * 3600 * 1000 (one day in milisecods). xAxis: { tickInterval: 24 * 3600 * 1000 }
-
$(function () { Highcharts.stockChart('container', { chart: { width: 500, height: 300 }, title: { text: 'AAPL Stock Price' }, xAxis: { ...
-
您正在寻找的是xAxis的“min”和“max”属性: http://api.highcharts.com/highstock#xAxis.min http://api.highcharts.com/highstock#xAxis.max 如果指定值,则不应自动为您计算它们。 如果这不起作用,您能否在http://JSfiddle.net上发布您的代码,以便我可以看看? What you're looking for is the "min" and "max" attributes of the xAxi ...
-
和yAxis一样,你需要使用plotLines http://api.highcharts.com/highcharts#xAxis.plotLines Highstock: http : //jsfiddle.net/kZkWZ/ value: Date.UTC(2011,3,1), 值应该是js时间戳,因为xAxis具有日期时间类型。 In the same way as in the yAxis, you need to use plotLines http://api.highcharts.com ...
-
你有没有试图把你的xAxis对象放在选项中? 看起来在这种情况下它可以正常工作: "options":{ "xAxis": {}, // try commenting this line "rangeSelector": { "allButtonsEnabled": true, "enabled": true, "selected": 1, "buttons": [{ "type": 'month', ...
-
从您想要在图表中显示的日期开始数据。 如果没有数据,则将y值赋予null 在您的情况下,您希望xAxis的min为Date.UTC(2012,1,24,16,44,10) 所以从中开始数据 data: [ [Date.UTC(2012, 1, 24, 16, 44, 10), null], [Date.UTC(2013, 6, 24, 16, 44, 10), 336000.], [Date.UTC(2013, 6, 27, 13, 57, 36), 393500.] ] 这将从您想要的那天开始制作xAxi ...
-
尝试将dataGrouping设置为false // other settings here plotOptions : { area : { // change this to the chart type you use dataGrouping : { enabled: false } } } // other settings here Try setting the dataGrouping enabled as false ...
-
迟到了,但我认为你需要使用像这样的labels , xAxis:{ labels: { formatter: function() { return Highcharts.dateFormat('%e. %b', this.value - 3600000 //needed otherwise it will start from 1 date of month ); } ...