match

Count match ratio between two dataset

末鹿安然 提交于 2019-12-24 09:52:39
问题 I have two dataset wanted to count match Ratio > events_data LONGITUDE LATITUDE matchvalue 1 122.5 9.5 0.006269592 2 122.5 10.5 0.050156740 3 125.5 10.5 0.043887147 4 146.5 40.5 0.048213166 5 142.5 40.5 0.035078370 6 146.5 40.5 0.028213166 > events LATITUDE LONGITUDE 1 9.880 124.1167 2 37.156 144.6611 using events(within 5 both in latitude and longitude) to select data in events_data when events_data.matchvalue > 0.04, set this row data in events_data is ture, or is flase count match Ratio =

Arabic characters using preg_match() function

有些话、适合烂在心里 提交于 2019-12-24 09:01:37
问题 I am trying to use preg_match() to check Arabic and English characters only, i used this code: preg_match("/^[a-zA-Zأ-ي]*$/",$name) but still, it is not working. EDIT: The code that does not work: if($name == '' || $email =='') { echo("<div class=\"error\">fill all fields</div>"); } else if (!preg_match("/^[a-zA-Zأ-ي\s]*$/",$name)) { echo("<div class=\"error\">Only letters and white space allowed</div>"); } else if (strlen($name) < 6) { echo("<div class=\"error\">NONONONO les than 6</div>");

Test Match and Order between two vectors in R

拟墨画扇 提交于 2019-12-24 08:49:04
问题 I would like to test the match and order between two vectors. I'm aware of the match function; are there overlays to assess the order simultaneously? For example: x <- c("a", "b", "c") y <- c("b", "a", "c") x %in% y There are perfect matches, but the ordering is not correct. Thoughts on how to identify that? Thanks. 回答1: test_match_order <- function(x,y) { if (all(x==y)) print('Perfect match in same order') if (!all(x==y) && all(sort(x)==sort(y))) print('Perfect match in wrong order') if (

Getting last match from multiple matches

半世苍凉 提交于 2019-12-24 08:46:33
问题 I am trying to match and get the last occurrence of a pattern in my file using notepad++. My text: X12 Source =asdjkasjd file="x/y1.dun" "x/y2.dun" "x/y3.dun" asds12 X22 p/q/xy.dun asda=23 source =asdf X44 1000 1001 file="abc.dun" What I expect using find-and-replace is this: X12 x/y3.dun X22 p/q/xy.dun X44 abc.dun What I have tried so far: (X\d{2}).*?([^"\s]+dun)((?!X\d{2}).)* replace with: $1\t\t$2\n But it returns me this: X12 x/y1.dun //Which is the first match X22 p/q/xy.dun X44 abc.dun

Regex: String match including punctuation

十年热恋 提交于 2019-12-24 07:08:01
问题 From another question, I have this expression to match words in a sentence: var sentence = "Exclamation! Question? Full stop. Ellipsis..."; console.log(sentence.toLowerCase().match(/\w+(?:'\w+)*/g)); It works perfectly. However, now I am looking for a way to match exclamation marks, question marks, and full stops separately. The result should look like this: [ "exclamation", "!", "question", "?", "full", "stop", ".", "ellipsis", "." ] Only matching one dot from the ellipsis, not all three

Index match x 2?

牧云@^-^@ 提交于 2019-12-24 06:53:08
问题 I am using the following index match formula: =IFERROR(INDEX(Data!V:V,MATCH(Home!F16,Data!C:C,0)),INDEX(Contacts!E:E,Home!H16 & "*",Contacts!B:B,0)) I am trying to lookup a vlaue on sheet Data, and if the value is not found then look up the value on sheet contacts. This always seems to be returning 0. Please can someone show me where i am going wrong? 回答1: You are missing the MATCH on the second INDEX: =IFERROR(INDEX(Data!V:V,MATCH(Home!F16,Data!C:C,0)),INDEX(Contacts!E:E,MATCH(Home!H16 & "*"

conditional data.table match for subset of data.table

假如想象 提交于 2019-12-24 06:44:43
问题 This post is related to the previous post here: match rows of two data.tables to fill subset of a data.table Not sure how I can integrate them together. I have a situation where other than the NA for one column of DT1, a couple of more conditions should apply for merging, but that doesn't work. > DT1 <- data.table(colA = c(1,1, 2,2,2,3,3), colB = c('A', NA, 'AA', 'B', NA, 'A', 'C'), timeA = c(2,4,3,4,6,1,4)) > DT1 colA colB timeA 1: 1 A 2 2: 1 <NA> 4 3: 2 AA 3 4: 2 B 4 5: 2 <NA> 6 6: 3 A 1 7:

Ignore date in a string with numbers using regular expression

十年热恋 提交于 2019-12-24 03:51:28
问题 I have a little Problem. i use [0-9\,.]* to finde a decimal in a string. And ([^\s]+) to find the text behind the first number. The string looks normally like this. 1 number a text and than a date: 1.023,45 stück 24.05.10 but sometimes I had just the date and then i become 240510 as decimal. And sometimes I had just the decimal. How should I modify the regex to find the date if existing and remove it? And then look for a decimal an select this if existing. Thanks in advance. 回答1: Divide and

smart match operator for hash of hash

一笑奈何 提交于 2019-12-24 03:12:41
问题 I want to match keys of a hash of hash with regexp . $line=" Cluster(A,B):A(T) M(S)"; $reg="Cluster"; my ( $cluster, $characters ) = split (/:/,$line); $HoH{$cluster}={split /[( )]+/,$characters } ; foreach $value(keys %HoH){ foreach $characters (keys %{$HoH{$cluster}}){ print "$value:$characters\n" if /$reg/ ~~ %HoH; } } now Output is : Cluster(A,B):A Cluster(A,B):M This code is works fine with this sample data,but not with real data!! my data is more complicated but the structure is the

一般图最大匹配——带花树模板

杀马特。学长 韩版系。学妹 提交于 2019-12-24 02:51:48
偶然碰到这个算法,学习下。 这样可以在O(n^3)的时间内找出非二分图的最大匹配。 #include <cstdio> #include <algorithm> #include <set> #include <vector> using namespace std; const int NMax=401; int Next[NMax]; int spouse[NMax]; int belong[NMax]; int findb(int a){ return belong[a]==a?a:belong[a]=findb(belong[a]); } void together(int a,int b){ a=findb(a),b=findb(b); if (a!=b)belong[a]=b; } vector<int> E[NMax]; int N; int Q[NMax],bot; int mark[NMax]; int visited[NMax]; int findLCA(int x,int y){ static int t=0; t++; while (1){ if (x!=-1){ x=findb(x); if (visited[x]==t)return x; visited[x]=t; if (spouse[x]!=-1)x=Next[spouse[x]]; else x=