r,matching,string-matching,levenshtein-distance,fuzzy-search
You can merge these data frames z <- merge(df1,df2,by='release_date',suffixes=c('.df1','.df2')) which will give you a cartesian product (i.e. all possible combinations between df1 and df2 for the same release_date, and then calculate the Levenshtein distance by: z$L.dist <- lenvenshteinSim(z$title.df1,z$title.df2) Having z$L.dist, you can filter the desired rows: subset(z,L.dist > 0.85) Update...
attributes,document,matching,value,microstrategy
You can't... or you can try to add the attribute year in the report with year-of-observation and put a filter year = year-of-observation, at this point many things can happen: If the two attributes have no relationship, the lookup table for year will be added to your report query in...
matlab,matching,feature-detection,feature-extraction,matlab-cvst
The reason why I got the error massage mentioned above is because the page is for R2014a,but my MATLAB is R2012b,so it is a version problem.We just need to change the code like this: [fMatrix, epipolarInliers, status] = estimateFundamentalMatrix(matchedPoints1.Location, ... matchedPoints2.Location, 'Method', 'RANSAC', 'NumTrials', 10000, 'DistanceThreshold', ... 0.1, 'Confidence', 99.99);...
If you want to get these substrings and also trim them, you can use the following regex: String rx = "\\$\\s*([^$]*)\\s*\\$"; Sample code: String str = ")(&^%$ HELLO $#)(&^%..$ this Is the text $KJHGFIUYTRMNBVkjh$I need$gfd987654"; String rx = "\\$\\s*([^$]*)\\s*\\$"; Pattern ptrn = Pattern.compile(rx); Matcher m = ptrn.matcher(str); while (m.find()) {...
Try lst <- split(1:ncol(df1),cumsum(grepl('Name', colnames(df1)))) lst2 <- lapply(lst, function(i) {x1 <- na.omit(df1[i]) colnames(x1)[1] <- 'Name' aggregate(.~ Name, x1, mean)}) res <- Reduce(function(...) merge(..., by='Name', all=TRUE), lst2) head(res,2) # Name Taska Bonda Goala Taskb Bondb Goalb Rapport Client #1 Adam Tharker 24.0 24.0 24.0 24 26.0 23.0 NA NA #2 Adam...
java,regex,pattern-matching,group,matching
You could use the below regex. ^(?:(\d+)\s+(?:(\S+)\s)?)?([^(]+\([^)]*\))$ DEMO String s = "1234 efg(567)"; Matcher m = Pattern.compile("^(?:(\\d+)\\s+(?:(\\S+)\\s)?)?([^(]+\\([^)]*\\))$").matcher(s); while(m.find()) { if(m.group(1) != null) System.out.println(m.group(1)); if(m.group(2) != null) System.out.println(m.group(2)); if(m.group(3) != null) System.out.println(m.group(3)); } ...
You can use BSXFUN to do it in a vectorized manner: rowsMatched = find(all(bsxfun(@eq, bigMatrix, matchingRow),2)); Notice that it will work for any number of columns, just matchingRow should have the same number of columns as bigMatrix....
The straightforward way to do it would be to create a new graph G' in which you have a vertex for every pair of connected edges in G, and an edge connects two vertices in G' whenever the corresponding edge pairs in G are less than 2 edges apart. You...
You are trying to use alternative lists in a regex, but instead you are using a character class ("[\\baddAction\\b|\\bintentFilter\\b]). With a character class, all characters in it are matched individually, not as a given sequence. You learnt the word boundary, you need to also learn how grouping works. You have...
python,regex,matching,regex-group
Context is important: re.match(r'\(', content) matches a literal parenthesis. re.match(r'\(*', content) matches 0 or more literal parentheses, thus making the parens optional (and allowing more than one of them, but that's clearly a bug). Since the intended behavior isn't "0 or more" but rather "0 or 1", this should probably...
regex,perl,if-statement,matching
How about using something like Text::Diff instead of building your own? See the comments for the explanation about how you didn't use a capture group to set $1....
c#,datatable,matching,relation
Well, you could of course use a little bit of LINQ by turning the data tables into IEnumerables using the AsEnumerable()1 extension method. I am using a few assumptions to illustrate this: "id" is the column with an integer value relating rows in FEData and SSFEData. "id" is the primary...
php,string,return,matching,vlookup
I suppouse data have not error, so don't do any test $c1 = file('csvurl.txt'); $l = count($c1); for ($i = 0; $i < $l; $i++) { list($name,$url) = explode(',', $c1[$i]); // making array $red['H001'] => 'URL1" $red[trim($name)] = trim($url); } unset($c1); $c = file('tickerMaster.txt'); $l = count($c); for ($i =...
http://www\.mywebsite\.com/video/.*?_ Try this. Make * non greedy. Better use http://www\.mywebsite\.com/video/[^_]*_ ...
I'm not sure if I quite understand your question. What I understood was that: You will compare images using keypoints You want to compare the size of matched keypoints First u want at least 2 images: Mat image1; //imread stuff here Mat image2; //imread stuff here Then detect keypoints in...
Wouldn't it be reasonable to assume that results from unapply would not change given the same string. Unfortunately, assuming isn't good enough for a (static) compiler. In order for memoizing to be a legal optimization, the compiler has to prove that the expression being memoized is pure and referentially...
Consider: awk -F 'FNR==NR{a[$1];b[$2];next} FNR==1 || ($2 in a && $3 in b)' file1 file2 The option -F expects an argument but no argument is provided intentionally. The result is that awk interprets the entirety of the code as the field separator. That is why that code does not run...
In the line Rectangle box2; // no default constructor, error you are trying to invoke the default constructor of Rectangle. The compiler does not generate such a default constructor anymore, because your Rectangle has a user defined constructor that takes 2 parameters. Therefore, you need to specify the parameters, like...
It seems I will be able to handle it using Amelia package: http://cran.r-project.org/web/packages/Amelia/vignettes/amelia.pdf#subsection.4.4 http://cran.r-project.org/web/packages/Amelia/Amelia.pdf and true, there is lots of materials on it on Cross Validated, e.g. http://stats.stackexchange.com/questions/95832/missing-values-nas-in-the-test-data-when-using-predict-lm-in-r @nograpes, thank you for all the hints!...
python,pandas,duplicates,dataframes,matching
This idea should work: Self join DF on c,d Apply condition of opposite values... A quick and dirty code ndf = merge(left=df1,right=df1,on=('c','d'),how='inner') out = ndf[(ndf.a_x == (-1)*ndf.a_y) & (ndf.b_x == (-1)*ndf.b_y)] Please let me know if this works...
Your formula is: =VLOOKUP(A8,Sheet1!A1:B285, 1, FALSE) If you take a look at VLOOKUP description, you will find the following description of the first parameter: The value you want to lookup. The value you want to look up must be in the first column of the range of cells you specify...
Simple: preg_match('/\d+\-\d+/', $string, $match); var_dump($matches); If you want to match all such patterns then use: preg_match_all('/\d+\-\d+/', $string, $matches); var_dump($matches); ...
If a structure implements MERGEABLE_QUEUE, it provides a function that takes a pair of queues of arbitrary type (as long as the two queues have the same type as each other) and produces a new queue. In particular, it can take two int queues and produce another int queue (and...
python,regex,url,beautifulsoup,matching
You could try this: import urllib2 import shutil urls = [] for i in range(10): urls.append(str('https://www.example.org/users/' + i)) def getUrl(urls): for url in urls: # Only a file_name based on url string file_name = url.replace('https://', '').replace('.', '_').replace('/', '_') response = urllib2.urlopen(url) with open(file_name, 'wb') as out_file: shutil.copyfileobj(response, out_file) getUrl(urls) ...
The following samples are all matched. $samples = Array( 'what is 4+3', 'what is 2 plus 7', 'what is 3 * 2', 'what is 3x2', 'what is 4 times 2' ); foreach($samples as $sample) { $sample = preg_replace('/(times)|\*/', 'x', $sample); $sample = str_replace('plus', '+', $sample); preg_match('/what is \d ?[+x] ?\d/',...
javascript,arrays,matching,javascript-objects
You just need to add an [i] to the second for loop ( for(var key in collection [i]) function where(collection, source) { var arr = []; // What's in a name? for(var i =0; i < collection.length; i++){ for(var key in collection[i]){ if(collection[i][key] === source[key]) { arr.push(collection[i]); } } }...
User the faster and more efficient package - data.table: install.packages("data.table") library(data.table) store the list of states that you are looking for in a data table list.states <- as.data.table(state_m) setnames(list.states,1,"STATE_CODE") # give some name to your column eg: STATE_CODE setkey(list.states,STATE_CODE) # merging would be done on STATE_CODE the entire data set...
You can use merge, as @MrFlick suggested: df.key <- data.frame( x=c(1,1,2,1,2), y=c(2,1,1,1,3), value=c(10,20,30,20,200)) ## df.add <- data.frame( x=c(1,2,2), y=c(1,1,3), value=c(20,30,300), a=rnorm(3), b=rpois(3,0)) ## > merge( x=df.key, y=df.add) x y value a b 1 1 1 20 0.9246104 0 2 1 1 20 0.9246104 0 3 2 1 30 0.2685016 0...
regex,permutation,matching,words
Using lookaheads, with "leap" as an example: \b(?=[a-z]*l)(?=[a-z]*e)(?=[a-z]*a)(?=[a-z]*p)[a-z]+\b Fiddle: http://refiddle.com/12u4 EDIT: I added \b anchors (word boundaries); the leading one is especially important, otherwise "appeal" might be captured three times ("appeal", "ppeal", "peal"). Feel free to use other anchors when appropriate (e.g. ^...$). By the way, this approach is also...
Try something along the lines of clear set more off *----- example data ----- input /// id str20 date treat match num 1 01feb2000 1 2 2 1 01apr2000 0 . . 1 01jan2002 1 3 1 2 01mar2000 1 3 0 2 01may2000 0 . . 3 01dec2002 1...
If I were you I'd just grab the number, and then outside of the regex work out if it fits within your bounds: '(\d+(?:\.\d{1,3})?)\s*/\s*10(?![^<]*/)' Update I realized mine failed when there were more than three decimal positions (grabbed the wrong number), so here's a better one: '(?<![\d.])(\d+(?:\.\d{1,3})?)\s*/\s*10(?![^<]*/)' ...
This is actually fairly straightforward to reconstruct, if you note that the values in index.treated are repeated M number of times, for those treated cases for which it is possible to find matches within the caliper distance. So, in your case, the the first two elements of index.control are the...
EDIT 2 : SOLUTION Thanks to the comments provided I managed to come up with a "not elegant" but working solution. B_rem = B; weights_error = [2 4 1]; match = zeros(size(A,1),2); for i = 1 : size(A,1) score = zeros(size(B_rem,1),1); for j =1 : size(B_rem,1) score(j) = sum(abs(A(i,:) -...
sql,file,comparison,substring,matching
Here's how I'd approach it (though using PowerShell rather than SQL): clear pushd c:\myPath\myFolder\ #read in the contents of the files $file1 = get-content("file1.txt") $file2 = get-content("file2.txt") #loop through each row of the whitespace separated file $file1 = $file1 | %{ #for each line, split on whitespace characters, returning the...
c++,algorithm,segmentation-fault,matching,hungarian-algorithm
I think what you want is a version of a maximum matching for a graph that is not bipartite. There is an algorithm described for this at http://en.wikipedia.org/wiki/Blossom_algorithm, and the very last paragraph talks about the weighted case. You want a minimum cost matching, but every maximum matching has the...
Edit: New code, I didn't understand your question the first time. This script reads both files, stores all IDs in a hash and then goes through all sequences in the first file. Only those sequences whose IDs are in the second file get written into the output file. Note that...
The problem is that you randomise the order of lalonde, but your input to GenMatch and Match are X and BalanceMat which still have the original order. When you then build your matched.data at the end, you are subsetting using indices which don't tie into lalonde any more. Try again...
perl,hash,matching,fuzzy-search
A lot of time it is easier to prep your data ahead of time. To make your code simpler later. Here is what I would do create a reverse hash of non-punctuation names to the id. When looping the file I just have to have to compare against my non-punctuation...
if { [regexp {rise_constraints|fall_constraint} $line] } Doesn't work because there is no rise_constraints in the lines. There is rise_constraint with no s. Also, try to better indent your code next time....
An easy way to approach this is to make a hash: library(dplyr) library(digest) df1 %>% rowwise() %>% do( data.frame(., id=digest( paste(.$a1,.$b1,.$c1), algo="md5"), stringsAsFactors=FALSE)) %>% ungroup() df2 %>% rowwise() %>% do( data.frame(., id=digest( paste(.$a2,.$b2,.$c2), algo="md5"), stringsAsFactors=FALSE)) %>% ungroup() which would produce the following for df1: a1 b1 c1 id 1 1...
I would use @Casimir's answer for this purpose.. If you are looking for a regex.. use the below pattern: <script[^>]*id="(?!pagespeed\b)[^"]+".*<\/script> See DEMO...
python,list,pandas,dataframes,matching
Your question still doesn't seem to have enough information to find the real problem. This quick example shows that your attempt can work just fine: import pandas as pd df = pd.DataFrame({'x': [4, 5, 6], 'month': [1, 2, 3]}) some_list = [2, 3] df[df['month'].isin(some_list)] = 99 df Out[13]: month x...
Actually, there are some algorithms from computational biology and genetics that might be suited for fast numbers matching, and also in a field of sequence pattern mining. Check "A FAST Pattern Matching Algorithm" by S. S. Sheik, Sumit K. Aggarwal Anindya Poddar N. Balakrishnan,‡ and K. Sekar Also, it appears...
I should start by saying that I have never used those packages and functions before, my answer is purely based on playing with your code and the functions documentation. It seems that there is a poorly documented, unwarned, precedence of Weight.matrix over exact in the Match() function. There's a hint...
From help(match): "match returns a vector of the positions of (first) matches of its first argument in its second." So it looks at each element in names(current_qty) and returns the position of it in trade_order. So for example it sees "ivvb11" in the second position on trade_order. Then this gets...
algorithm,graph-algorithm,matching,scilab
I do not know Scilab I am afraid, but if you are willing to use Python it is very easy as the Networkx library provides support for this function: import networkx as nx import networkx.algorithms.matching as matching def C(i,j): return i*j n=40 G=nx.Graph() for i in range(n): for j in...
There's a reason the auto-generated equals method doesn't do what you're suggesting. The canEqual convention is a common and well-documented one, because it allows for handling a broader set of common use cases. You don't always want to exclude all sub classes when implementing an equals method, only ones that...
sql,ruby-on-rails,ruby,ruby-on-rails-4,matching
Finding related jobs according to some number of criteria, and weighting the related jobs according to the "closeness of match" certainly sounds like it is a task for the Job class. I'd create a method (perhaps 'get_related_weighted_jobs') in the Job class. Inside that method, use the Job instance's attributes to...
bash,shell,sorting,matching,file-handling
#!/bin/bash # If there are no files match File_*.*.txt # replace File_*.*.txt by empty string shopt -s nullglob for i in File_*.*.txt; do echo "processing file $i" IFS="_." read foo num1 num2 foo <<< "$i" printf -v dir1 "Dir_%03d" "$num1" printf -v dir2 "Dir_%03d" "$num2" mkdir -pv "$dir1" "$dir2" cp...
This question is the continuation of your previous question. Based on that knowledge here is the answer to your question: function getAgentForRejectedUser($rejectedUser, $arrayListeAgence) { foreach ($arrayListeAgence as $agent => $users) { foreach ($users as $user) { $data = explode(' ', $user); if ($data[0] == $rejectedUser) { return $agent; } }...
registration,matching,point-cloud-library,point-clouds
This is also closely related to object recognition, which in the world of 3D model-based perception is closely tied to pose estimation. One issue that frequently pops up in object recognition is what scales at which to ignore features; calculating features at a larger scale is a way to get...
This will work: var full_id = $("input[id ^='test-id-']"); // get the full ID var res = full_id[0].id.split("-"); // split it on "-" var yourId = res[2]; // last part is your ID alert (yourId); // shout it out ...
matlab,matching,vision,correspondence
This is most probably an imshow issue. The function imshow excepts the image to be in the range [0, 255] if it is a uint8, or [0.0, 1.0] if floating point. Try: imshow(min_cost, []); Note, the empty array for the second argument. This tells Matlab to figure out the scaling....
matlab,image-processing,matching,surf,matlab-cvst
To understand it further I tried the following code in this link. % Extract SURF features I = imread('cameraman.tif'); points = detectSURFFeatures(I); [features, valid_points] = extractFeatures(I, points); % Visualize 10 strongest SURF features, including their % scales and orientation which were determined during the % descriptor extraction process. imshow(I); hold...
You could use left_join from dplyr: > design # ss clusters ICC items CondNum #1 300 10 0.05 10 1 #2 300 10 0.05 20 2 #3 300 10 0.05 50 3 #4 300 10 0.05 70 4 #5 300 10 0.10 10 5 > condition # ss clusters ICC...
I find a similar problem here and based on that i come up with this solution. For the first part of your problem to select how many time same five player were on the ice when the goal is scored your query could look like this: SELECT GROUP_CONCAT(t1.fk_gf_id) AS MinOfGoal,...
python,arrays,performance,numpy,matching
Since bigx is always evenly spaced, it's quite straightforward to just directly compute the indices: start = bigx[0] step = bigx[1] - bigx[0] indices = ((x - start)/step).round().astype(int) Linear time, no searching necessary....
There are quite a few ways to extract the data. The simplest form would be grep. GNU grep: You can grab the required data using GNU grep with PCRE option -P: $ cat file xxx_component1-1.0-2-2acd314.xc-linux-x86-64-Release-devel.r xxx_component2-3.0-1-fg3sdhd.xc-linux-x86-64-Release-devel.r xxx_component3-1.0-2-3gsjcgd.xc-linux-x86-64-Release-devel.r xxx_component4-0.0-2-2acd314.xc-linux-x86-64-Release-devel.r $ grep -oP '(?<=_)[^-]*' file component1 component2 component3 component4 Here we use...
Looks like a dependency problem. Do you have jsonpath included via some other dependency? If this is the case you might want to try including the standalone version with all dependencies excluded as described here: http://wiremock.org/getting-started.html...
string,algorithm,matching,knuth-morris-pratt,rabin-karp
When you want to search for multiple patterns tipically the correct choice is to use Aho-Corasick which is somewhat a generalization of KMP. Now in your case you are only searching for 3 patterns so it may be the case that KMP is not that much slower(at most three times),...
r,matching,cumulative-frequency
findInterval() is perfect for this: set.seed(1); cumFreqDist <- data.frame(Time=c(0,4,6,8,12,16,18,20,24,100), cumfreq=c(0.0000000,0.9009009,1.8018018,7.5075075,23.4234234,39.6396396,53.4534535,58.2582583,75.3753754,100.0000000) ); testData <- data.frame(x=runif(10000)*100); testData$Time <- cumFreqDist$Time[findInterval(testData$x,cumFreqDist$cumfreq)]; head(testData,20); ## x Time ## 1 26.550866 12 ## 2 37.212390 12 ## 3 57.285336 18 ## 4 90.820779 24 ## 5 20.168193 8 ## 6 89.838968 24 ## 7 94.467527 24 ##...
python,opencv,image-processing,matching,feature-detection
matches returns a list of structures where each structure contains several fields... among them are two important fields: queryIdx - The index of the feature into kp1 that matches trainIdx - The index of the feature into kp2 that matches You'd use these to index into kp1 and kp2 and...
jquery,clone,matching,custom-data-attribute
You may try this (Example): var c = 'usa', t = '1940'; $("li[data-c='" + c + "'][data-t='" + t + "']").clone().appendTo(".someClass" ); Elements that matches both data attribute will be cloned and appended....
javascript,css,function,matching
You pass the (numeric, 0 based) index of the answer to the function select based on the button you clicked. You compare this to the ans property, which has the value 'A' or 'B' for the first questions. 0, obviously, is not equal to 'A'. So change ans to a...
java,algorithm,colors,gradient,matching
To generate a gradient between two color values, you can just linearly interpolate between them. This will basically work in any color space, although if the transformation between two color spaces is not linear, the gradient obtained by linearly interpolating in one space will not be linear in the other....