text-processing

Does an empty string contain an empty string in C++?

故事扮演 提交于 2019-11-30 17:43:25
问题 Just had an interesting argument in the comment to one of my questions. My opponent claims that the statement "" does not contain "" is wrong. My reasoning is that if "" contained another "" , that one would also contain "" and so on. Who is wrong? P.S. I am talking about a std::string P.S. P.S I was not talking about substrings, but even if I add to my question " as a substring", it still makes no sense. An empty substring is nonsense . If you allow empty substrings to be contained in

Linux join utility complains about input file not being sorted

♀尐吖头ヾ 提交于 2019-11-30 14:36:56
I have two files: file1 has the format: field1;field2;field3;field4 (file1 is initially unsorted) file2 has the format: field1 (file2 is sorted) I run the 2 following commands: sort -t\; -k1 file1 -o file1 # to sort file 1 join -t\; -1 1 -2 1 -o 1.1 1.2 1.3 1.4 file1 file2 I get the following message: join: file1:27497: is not sorted: line_which_was_identified_as_out_of_order Why is this happening ? (I also tried to sort file1 taking into consideration the entire line not only the first filed of the line but with no success) sort -t\; -c file1 doesn't output anything. Around line 27497, the

difference between similar() and concordance in nltk

不打扰是莪最后的温柔 提交于 2019-11-30 14:23:28
问题 I have read the text1.similar("monstrous") and text1.concordance("monstrous") from this. Where I couldn't get the satisfactory answer for the difference between text1.concordance('monstrous') and text1.similar('monstrous') of natural language processing toolkit in python. So would you please give the explanation with an example in detail? 回答1: Using concordance(token) gives you the context surrounding the argument token . It will show you the sentences where token appears. Using similar(token

How to proceed with NLP task for recognizing intent and slots

谁说我不能喝 提交于 2019-11-30 10:24:43
问题 I wanted to write a program for asking questions about weather. What are the algorithms and techniques I should start looking at. ex: Will it be sunny this weekend in Chicago. I wanted to know the intent = weather query, date = this weekend, location = chicago. User can express the same query in many forms. I would like to solve some constrained form and looking for ideas on how to get started. The solution needs to be just good enough. 回答1: Since your input is in the natural language form,

difference between similar() and concordance in nltk

♀尐吖头ヾ 提交于 2019-11-30 10:12:10
I have read the text1.similar("monstrous") and text1.concordance("monstrous") from this . Where I couldn't get the satisfactory answer for the difference between text1.concordance('monstrous') and text1.similar('monstrous') of natural language processing toolkit in python. So would you please give the explanation with an example in detail? Using concordance(token) gives you the context surrounding the argument token . It will show you the sentences where token appears. Using similar(token) returns a list of words that appear in the same context as token . In this case the the context is just

Perl add <a></a> around words within an HTML/XML tag

爷,独闯天下 提交于 2019-11-30 09:54:17
问题 I have a file formatted like this one: Eye color <p class="ul">Eye color, color</p> <p class="ul1">blue, cornflower blue, steely blue</p> <p class="ul1">velvet brown</p> <link rel="stylesheet" href="a.css"> </> weasel <p class="ul">weasel</p> <p class="ul1">musteline</p> <link rel="stylesheet" href="a.css"> </> Each word within the <p class="ul1"> separated by , should be wrapped in an <a> tag, like this: Eye color <p class="ul">Eye color, color</p> <p class="ul1"><a href="entry://blue">blue<

How to get Git log with short stat in one line?

ぃ、小莉子 提交于 2019-11-30 08:21:24
Following command outputs following lines of text on console git log --pretty=format:"%h;%ai;%s" --shortstat ed6e0ab;2014-01-07 16:32:39 +0530;Foo 3 files changed, 14 insertions(+), 13 deletions(-) cdfbb10;2014-01-07 14:59:48 +0530;Bar 1 file changed, 21 insertions(+) 5fde3e1;2014-01-06 17:26:40 +0530;Merge Baz 772b277;2014-01-06 17:09:42 +0530;Qux 7 files changed, 72 insertions(+), 7 deletions(-) I'm interested in having above format to be displayed like this ed6e0ab;2014-01-07 16:32:39 +0530;Foo;3;14;13 cdfbb10;2014-01-07 14:59:48 +0530;Bar;1;21;0 5fde3e1;2014-01-06 17:26:40 +0530;Merge Baz

BLEU score implementation for sentence similarity detection

家住魔仙堡 提交于 2019-11-30 07:49:46
I need to calculate BLEU score for identifying whether two sentences are similar or not.I have read some articles which are mostly about BLEU score for Measuring Machine translation accuracy.But i'm in need of a BLEU score to find out similarity between sentences in a same language[English].(i.e)(Both the sentences are in English).Thanks in anticipation. Well, if you just want to calculate the BLEU score, it's straightforward. Treat one sentence as the reference translation and the other as the candidate translation. dmcer For sentence level comparisons, use smoothed BLEU The standard BLEU

Extract text between two strings repeatedly using sed or awk? [duplicate]

霸气de小男生 提交于 2019-11-30 04:37:18
问题 This question already has answers here : How to use sed/grep to extract text between two words? (11 answers) Closed last year . I have a file called 'plainlinks' that looks like this: 13080. ftp://ftp3.ncdc.noaa.gov/pub/data/noaa/999999-94092-2012.gz 13081. ftp://ftp3.ncdc.noaa.gov/pub/data/noaa/999999-94094-2012.gz 13082. ftp://ftp3.ncdc.noaa.gov/pub/data/noaa/999999-94096-2012.gz 13083. ftp://ftp3.ncdc.noaa.gov/pub/data/noaa/999999-94097-2012.gz 13084. ftp://ftp3.ncdc.noaa.gov/pub/data/noaa

How to get bag of words from textual data? [closed]

不打扰是莪最后的温柔 提交于 2019-11-29 23:10:24
I am working on prediction problem using a large textual dataset. I am implementing Bag of Words Model. What should be the best way to get the bag of words? Right now, I have tf-idf of the various words and the number of words is too large to use it for further assignments. If I use tf-idf criteria, what should be the tf-idf threshold for getting bag of words? Or should I use some other algorithms. I am using python. Using the collections.Counter class >>> import collections, re >>> texts = ['John likes to watch movies. Mary likes too.', 'John also likes to watch football games.'] >>>