matching

Python&R:警告信息管理

谁都会走 提交于 2019-12-05 14:34:18
计算机程序有时很人性化,比如给你警告提示信息; 计算机程序有时又非常不人性化,比如动不动就给你警告提示...... 如果你的程序是要给客户使用,有运行美化要求; 再尤其是比如警告出现在循环里的情况,那么每次循环都要打印出一堆警告信息......那就十分扯淡了。 怎么办? 显然,警告(Warning)并不是错误(Error),程序并不会因警告的出现而中止运行。 那些原始开发者一定早已考虑到这一点,设置了可供调整的警告输出模式。 我们以Python和R为例,看看基本的警告信息管理操作。 (一)Python 我们编写以下程序: import warnings as w if 1==1: w.warn('警告!!!') 运行结果为: Warning (from warnings module): File "D:/warnings.py", line 3 w.warn('警告!!!') UserWarning: 警告!!! 1)当使用命令行模式执行程序时,可在执行命令里加入-W ignore: python -W ignore XXX.py 此时运行结果不输出警告。 2)也可在程序中导入warnings模块,使用警告过滤器。 import warnings as w w.filterwarnings("ignore") if 1==1: w.warn('警告!!!')

ANTLR: how to parse a region within matching brackets with a lexer

喜夏-厌秋 提交于 2019-12-05 12:20:49
i want to parse something like this in my lexer: ( begin expression ) where expressions are also surrounded by brackets. it isn't important what is in the expression, i just want to have all what's between the (begin and the matching ) as a token. an example would be: (begin (define x (+ 1 2))) so the text of the token should be (define x (+ 1 2))) something like PROGRAM : LPAREN BEGIN .* RPAREN; does (obviously) not work because as soon as he sees a ")", he thinks the rule is over, but i need the matching bracket for this. how can i do that? Bart Kiers Inside lexer rules, you can invoke rules

Prefix vs Suffix Trie in String Matching

独自空忆成欢 提交于 2019-12-05 11:47:30
I'm not too well-versed about the actual algorithms used in string matching with tries. I'm wondering why there seems to be more focus on suffix tries for string matching rather than prefix tries. Can we not use prefix tries for substring matching also? Put in another way, what are the advantages of suffix tries over prefix tries? .retteb era seirt xiferp ,drawkcab daer uoy fI Seriously. Suffix tries allow you to traverse from the beginning of a string. 来源: https://stackoverflow.com/questions/6692441/prefix-vs-suffix-trie-in-string-matching

SQL pattern matching

 ̄綄美尐妖づ 提交于 2019-12-05 10:17:54
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 Soundex(), Difference(), Fuzzy string matching using Levenshtein distance algorithm. You didn't say what

How do I match similar coordinates using Python?

北城余情 提交于 2019-12-05 07:42:20
Background: I have been given four catalogues of data, the first of which (let's call Cat1) gives the coordinates (in right ascension and declination, RA and Dec) for radio sources in fields 1 and 2, the second catalogue (Cat2) gives the RA and Dec for radio sources and infrared (IR) sources in field 1, the third catalogue (Cat3) gives the RA and Dec for radio and IR sources in field 2, and the fourth catalogue (Cat4) gives the RA and Dec for optical sources in fields 1 and 2. Cat1 has approximately 2000 sources for field 2, keeping in mind that some of the sources are actually measured

Partial subtree-matching algorithm

五迷三道 提交于 2019-12-05 03:46:07
问题 I searched the forums but I couldn't figure it out if the other similar questions are necessarily related to this one. What I'm trying to do is match a subtree to a tree of objects. I know there are pattern matching algorithms based on suffix trees or automata, but I'm not sure whether they apply here. I am trying to match the subtree given by the red nodes in the picture against the bigger tree, regardless of the overall structure of the tree or whether the red nodes have children or not.

n-dimensional matching algorithm

本小妞迷上赌 提交于 2019-12-05 00:26:48
问题 Looking for some advice here. Does anyone know a good place to start looking into matching algorithm in a n-dimensional space. For example, any dating site out there must be using some sort of algorithm to match 2 people. What I have read is that we can map characteristics of a person in a n-dimensional array with a point system for each characteristic. Once we have all (available) characteristics of a person, we can represent this person in a point within a n-dimensional array. Then, to

How to resolve the difference between the values attained in the Web API and the ones attained through the source in ws4j?

喜欢而已 提交于 2019-12-04 17:49:36
I developed the following API for semantic matching for sentences using ws4j library. But im failing to get the semantic similarities. The ouptut is attached as an image which shows values which are redundant or 0. Is there any library which is missed out to be called? package ws4jv01; import edu.cmu.lti.lexical_db.ILexicalDatabase; import edu.cmu.lti.lexical_db.NictWordNet; import edu.cmu.lti.ws4j.RelatednessCalculator; import edu.cmu.lti.ws4j.impl.HirstStOnge; import edu.cmu.lti.ws4j.impl.JiangConrath; import edu.cmu.lti.ws4j.impl.LeacockChodorow; import edu.cmu.lti.ws4j.impl.Lesk; import

Matching two series of Mfcc coefficients

落花浮王杯 提交于 2019-12-04 16:25:40
I have extracted two series MFCC coefficients from two around 30 second audio files consisting of the same speech content. The audio files are recorded at the same location from different sources. An estimation should be made whether the audio contains the same conversation or a different conversation. Currently I have tested a correlation calculation of the two Mfcc series but the result is not very reasonable. Are there best practices for this scenario? I had the same problem and the solution for it was to match the two arrays of MFCCs using the Dynamic Time Warping algorithm. After

Oracle SQL Regexp_replace matching

限于喜欢 提交于 2019-12-04 16:11:07
Here is a funky matching that I need to accomplish. A5.1.9.11.2 Needs to become: A05.01.09.11.02 The amount of DOT sections will vary from none to many. And the letter "A" will always be there and always be 1 character. I would like to use the regexp_replace() function in order to use this as a sorting mechanism. Thanks. Oracle SQL doesn't support lookaround assertions, which would be useful for this case: s/([0-9](?<![0-9]))/0\1/g You'll have to use at least two replacements: REGEXP_REPLACE(REGEXP_REPLACE(col, '([0-9]+)', '0\1'), '0([0-9]{2})', '\1') 来源: https://stackoverflow.com/questions