Note that there are some explanatory texts on larger screens.

plurals
  1. POWord match in multiple files
    primarykey
    data
    text
    <p>I have a corpus of words like these. There are more than 3000 words. But there are 2 files:</p> <pre class="lang-none prettyprint-override"><code>File #1: #fabulous 7.526 2301 2 #excellent 7.247 2612 3 #superb 7.199 1660 2 #perfection 7.099 3004 4 #terrific 6.922 629 1 #magnificent 6.672 490 1 File #2: ) #perfect 6.021 511 2 ? #great 5.995 249 1 ! #magnificent 5.979 245 1 ) #ideal 5.925 232 1 day #great 5.867 219 1 bed #perfect 5.858 217 1 ) #heavenly 5.73 191 1 night #perfect 5.671 180 1 night #great 5.654 177 1 . #partytime 5.427 141 1 </code></pre> <p>I have many sentences like this, more than 3000 lines like below:</p> <pre class="lang-none prettyprint-override"><code>superb, All I know is the road for that Lomardi start at TONIGHT!!!! We will set a record for a pre-season MNF I can guarantee it, perfection. All Blue and White fam, we r meeting at Golden Corral for dinner to night at 6pm....great </code></pre> <p>I have to go through every line and do the following task:<br> 1) find if those corpus of words match anywhere in the sentences<br> 2) find if those corpus of words match leading and trailing of sentences </p> <p>I am able to do part 2) and not part 1). I can do it but finding a efficient way. I have the following code:</p> <pre><code>for line in sys.stdin: (id,num,senti,words) = re.split("\t+",line.strip()) sentence = re.split("\s+", words.strip().lower()) for line1 in f1: #f1 is the file containing all corpus of words like File #1 (term2,sentimentScore,numPos,numNeg) = re.split("\t", line1.strip()) wordanalysis["trail"] = found if re.match(sentence[(len(sentence)-1)],term2.lower()) else not(found) wordanalysis["lead"] = found if re.match(sentence[0],term2.lower()) else not(found) for line in sys.stdin: (id,num,senti,words) = re.split("\t+",line.strip()) sentence = re.split("\s+", words.strip().lower()) for line1 in f1: #f1 is the file containing all corpus of words like File #1 (term2,sentimentScore,numPos,numNeg) = re.split("\t", line1.strip()) wordanalysis["trail"] = found if re.match(sentence[(len(sentence)-1)],term2.lower()) else not(found) wordanalysis["lead"] = found if re.match(sentence[0],term2.lower()) else not(found) for line1 in f2: #f2 is the file containing all corpus of words like File #2 (term2,sentimentScore,numPos,numNeg) = re.split("\t", line1.strip()) wordanalysis["trail_2"] = found if re.match(sentence[(len(sentence)-1)],term.lower()) else not(found) wordanalysis["lead_2"] = found if re.match(sentence[0],term.lower()) else not(found) </code></pre> <p>Am I doing this right? Is there a better way to do it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload