matching

Why aren't these non-capturing regex groups working right?

血红的双手。 提交于 2019-12-23 13:25:17
问题 So I spent a lot of time on another stack overflow question, and the same problem came up with a previous one. Non-capturing groups aren't working as I'd expect them to, or so I believe. This is a silly example along the lines of someone else's CSS test string... Here's my regex: (?:(rgb\([^)]*\)|\S+)(?:[ ]+)?)* And here's the test string: 1px solid rgb(255, 255, 255) test rgb(255, 255, 255) I'm expecting match groups of "1px","solid", "rgb(255, 255, 255)", "test", "rgb(255, 255, 255)" But I

How to assign identical unique IDs to matching observations between two dataframes in r?

我是研究僧i 提交于 2019-12-23 09:07:30
问题 I have a practical question when I have two (or more) data frames and want to assign unique IDs for each matching observation within each and across both datasets e.g.: #1. Create dataframe df1: a1 <- c(1, 1, 1, 1, 2, 2, 2, 2, 1, 1) b1 <- c(1, 5, 3, 2, 3, 4, 5, 1, 5, 2) c1 <- c("white", "red", "black", "white", "red", "white", "black", "silver", "red", "green") df1 <- data.frame(a1, b1, c1) df1 a1 b1 c1 1 1 1 white 2 1 5 red 3 1 3 black 4 1 2 white 5 2 3 red 6 2 4 white 7 2 5 black 8 2 1

Mask / Zero out area outside specified ROI

孤街浪徒 提交于 2019-12-23 05:11:58
问题 I'm working on a project using OpenCV on template matching, and I want to limit the search region on an image. Image is captured continuously from a camera. Is there any way to Zero / mask out image outside ROI defined, so that template matching process can be specific on remaining region, faster and accurate? 回答1: Take a look at the cvSetImageROI function. void cvSetImageROI(IplImage* image, CvRect rect) Sets an image Region Of Interest (ROI) for a given rectangle. Parameters: image – A

find best subset from list of strings to match a given string

霸气de小男生 提交于 2019-12-22 08:43:56
问题 I have a string s = "mouse" and a list of string sub_strings = ["m", "o", "se", "e"] I need to find out what is the best and shortest matching subset of sub_strings the list that matches s. What is the best way to do this? The ideal result would be ["m", "o", "se"] since together they spell mose 回答1: You can use a regular expression: import re def matches(s, sub_strings): sub_strings = sorted(sub_strings, key=len, reverse=True) pattern = '|'.join(re.escape(substr) for substr in sub_strings)

postgres find zip codes near specific zip code

﹥>﹥吖頭↗ 提交于 2019-12-22 08:16:01
问题 Assuming a Postgres Table containing zip as varchar(10) I want to get either all results matching a specific zip or extend my results with entries close to the queried one in case there are not enough results. Say: A user searches for zip "56500" and my result-set returns 2 items running an exact match. In this case I want to perform a kind of like query that finds "565%" entries. Eventually I need to run this in one query. Any suggestions? 回答1: Something like this might be what you want:

SQL pattern matching

痞子三分冷 提交于 2019-12-22 06:47:34
问题 I have a question related to SQL. I want to match two fields for similarities and return a percentage on how similar it is. For example if I have a field called doc, which contains the following This is my first assignment in SQL and in another field I have something like My first assignment in SQL I want to know how I can check the similarities between the two and return by how much percent. I did some research and wanted a second opinion plus I never asked for source code. Ive looked at

How does the Hopcroft-Karp algorithm work?

吃可爱长大的小学妹 提交于 2019-12-21 09:27:24
问题 I am currently working on a project to pictorially explain the Hopcroft-Karp algorithm. I am using the pseudo-code from the Wikipedia article. I have also seen this algorithm implemented on Stack Overflow in Python This would do fantastically if only I didn't have to understand the algorithm completely to use it. My questions are as follows: What is the meaning of the Dist[] array in the pseudo-code, and how is the layering of the graph done in the Breadth-First-Search. I have a grasp on the

Matching inexact company names in Java

本秂侑毒 提交于 2019-12-21 09:24:29
问题 I have a database of companies. My application receives data that references a company by name, but the name may not exactly match the value in the database. I need to match the incoming data to the company it refers to. For instance, my database might contain a company with name "A. B. Widgets & Co Ltd." while my incoming data might reference "AB Widgets Limited", "A.B. Widgets and Co", or "A B Widgets". Some words in the company name (A B Widgets) are more important for matching than others

How to count the number of objects detected with Template Matching?

杀马特。学长 韩版系。学妹 提交于 2019-12-21 06:09:07
问题 I was reading the docs about template matching with opencv and python and in the last part about template matching with multiple objects, the code detect the 19 coins on the mario image but, is it possible to count the number of objects detected with some function on python like len() or any opencv method? Here is the code showed on the tutorial: http://docs.opencv.org/3.1.0/d4/dc6/tutorial_py_template_matching.html Template Matching Code: import cv2 import numpy as np from matplotlib import

How to count the number of objects detected with Template Matching?

折月煮酒 提交于 2019-12-21 06:09:02
问题 I was reading the docs about template matching with opencv and python and in the last part about template matching with multiple objects, the code detect the 19 coins on the mario image but, is it possible to count the number of objects detected with some function on python like len() or any opencv method? Here is the code showed on the tutorial: http://docs.opencv.org/3.1.0/d4/dc6/tutorial_py_template_matching.html Template Matching Code: import cv2 import numpy as np from matplotlib import