matching

Check if given string matches one of set of prefixes, effectively

杀马特。学长 韩版系。学妹 提交于 2019-12-11 02:34:48
问题 What algorithm to use to check if a given string matches one of set of prefixes, and which prefix from that set? Other variation: given path and a set of directories, how to check if path is in one of set of directories (assuming that there are no symbolic links, or they do not matter)? I'm interested in description or name of algorithm, or Perl module which solves this (or can be used to solve this). Edit Bonus points for solution which allow to effectively find 'is prefix of' relation

ERLANG - Pattern Matching

泄露秘密 提交于 2019-12-11 02:09:28
问题 I have a variable: Data = [[<<>>, [<<"10">>,<<"171">>], [<<"112">>,<<"Gen20267">>], [<<"52">>,<<"20100812-06:32:30.687">>]] I am trying to pattern match for two specific cases.. One where anything that resembles the outside structure - simply [] Anything inside goes I have tried [ _ ] but no go? The Second, for a specific pattern inside, like when I see a <<"10">> or <<"112">> or <<"52">> then I am going to take the right side which is the actual data into an atom. Basically the <<"10">> or <

Tuples partial match

∥☆過路亽.° 提交于 2019-12-11 00:38:13
问题 I have a tuple of tuples and a tuple. I'm interested to know which elements of the first tuple match the second tuple (if any), considering partial matches too. This is a filter function to demonstrate what I mean. def f(repo): pattern = (None, None, '1.3') for idx, item in enumerate(pattern): if item != None and item != repo[idx]: return False return True >>> repo = (('framework', 'django', '1.3'), ('cms', 'fein', '1.3'), ('cms', 'django-cms', '2.2')) >>> filter(f, repo) (('framework',

Equalizing luminance, brightness and contrast for a set of images

前提是你 提交于 2019-12-10 20:33:30
问题 I use MATLAB for a series of experiments where each eye gets stimulated with a different motiv from the images (binocular rivalry), like on the one is a bottle, on the other a watch. There is a Toolbox to adjust the luminance and spatial frequency (Shine toolbox), but that does not work for images where the background is simply transparent, like .png/.tif/.bmp etc. Moreover, the background which shall stay transparent gets included in the analysis and matching routine so that the objects in

no matching functions for call to constructor (c++) [duplicate]

穿精又带淫゛_ 提交于 2019-12-10 20:33:15
问题 This question already has answers here : What is an undefined reference/unresolved external symbol error and how do I fix it? (32 answers) Closed 6 years ago . EDIT Ok, I've done a bit of reading again for a few hours and I think I finally understand c++ OOP a bit better (at least the basics). I decided to rewrite the entire program and code a bit at a time and test more. I think i narrowed the errors i bit more this time. NamedStorm.h #include <string> #include <iostream> #ifndef NAMEDSTORM

How can I match the shortest possible sequence of characters that satisfy my regex pattern?

会有一股神秘感。 提交于 2019-12-10 18:47:35
问题 I've a string "ajjjjjjjjjaab" I want a pattern which will match the last "ab" and not the whole string or even "aab" . /a.*?b/ # returns two groups or /a.??b/ # matches last aab Neither works. 回答1: A simple way around your problem is to match: .*(a.*b) With the first .* being greedy, it matches as much as it can. Then you get a captured group with the match you really need, ( $1 ). Note that this assumes you're matching the last occurrence of the pattern. You may want .*(a.*?b) if you have

Matlab SURF points to pixel coordinates

…衆ロ難τιáo~ 提交于 2019-12-10 16:59:15
问题 I want to extract (x,y) pixel coordinates out of the SURF points returned, as an example in the example provided here using Matlab. It is clear that using 'ptsIn(1).Location' I can return the (x,y) coordinates of the point. But the points retuned included some decimal points as well, as an example (102.9268, 51.7285). Is there any way to convert this to pixel positions in the image plane, or just averaging these values will give the pixel positions? Thank you. 回答1: To understand it further I

indices of occurence of each row in MATLAB

你。 提交于 2019-12-10 11:26:02
问题 I have two matrices, A and B . ( B is continuous like 1:n ) I need to find all the occurrences of each individual row of B in A , and store those row indices accordingly in cell array C . See below for an example. A = [3,4,5;1,3,5;1,4,3;4,2,1] B = [1;2;3;4;5] Thus, C = {[2,3,4];[4];[1,2,3];[1,3,4];[1,2]} Note C does not need to be in a cell array for my application. I only suggest it because the row vectors of C are of unequal length. If you can suggest a work-around, this is fine too. I've

Machine Vision problem - Photo matching. Is a solution possible / known, using OpenCV?

时间秒杀一切 提交于 2019-12-10 10:39:35
问题 Having searched around on SO, and also checked on OpenCV list but not having found an answer, posting my query here. Problem: Match 2 photos of the same scene, shot from 2 slightly different camera angles, and with slightly different lens distortions, with slightly different zoom-levels, and shot under slightly different lighting conditions. Constraints: Slightly different in the above statements can be taken to mean max. of 10% in most cases. The scene in question is to be considered an

Matching IDs in two datasets

删除回忆录丶 提交于 2019-12-10 03:41:44
问题 I have two sets of data, comprising pre and a post data. Respondents have unique IDs, and I want to create a subset which includes only those who responded to both surveys. Example dataset: pre.data <- data.frame(ID = c(1:10), Y = sample(c("yes", "no"), 10, replace = TRUE), Survey = 1) post.data <- data.frame(ID = c(1:3,6:10), Y = sample(c("yes", "no"), 8, replace = TRUE), Survey = 2) all.data <- rbind(pre.data, post.data) I have the following function: match <- function(dat1, dat2, dat3){