-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnameidentifier.py
More file actions
31 lines (30 loc) · 789 Bytes
/
Copy pathnameidentifier.py
File metadata and controls
31 lines (30 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import spacy
from spacy import displacy
from collections import Counter
import en_core_web_sm
nlp = en_core_web_sm.load()
file1 = open("text.txt",'r')
text = file1.read()
text = text.replace("\n",' ')
print(text)
doc = nlp(text)
#doc = nlp('Harsha')
#print([(X.text, X.label_) for X in doc.ents])
inFile=open('./input/479k-english-words/customdictionary.txt', "a+")
with open('./input/479k-english-words/customdictionary.txt') as f:
words = f.readlines()
eng_words = [word.strip() for word in words]
#print(eng_words)
mylist = []
for X in doc.ents:
print([(X.text,X.label_)])
mylist.append(X.text)
print(mylist)
for word in mylist:
if word in eng_words:
continue
else:
inFile.write('\n')
inFile.write(str(word).lower())
inFile.close()
f.close()