mycorpus.txtapostrof zamienia x92
Human where's machine interface for lab abc computer applications
A where's survey of user opinion of computer system response time
stopwords.txt
let's
ain't
there's
Poniższy kod
corpus = set()
for line in open("path\\to\\mycorpus.txt"):
corpus.update(set(line.lower().split()))
print corpus
stoplist = set()
for line in open("C:\\Users\\Pankaj\\Desktop\\BTP\\stopwords_new.txt"):
stoplist.add(line.lower().strip())
print stoplist
daje następujący wynik
set(['a', "where's", 'abc', 'for', 'of', 'system', 'lab', 'machine', 'applications', 'computer', 'survey', 'user', 'human', 'time', 'interface', 'opinion', 'response'])
set(['let\x92s', 'ain\x92t', 'there\x92s'])
Dlaczego apostrof zmienia się w \ x92 w drugim zestawie?
Nigdy nie używaj edytorów Microsoft, jeśli chcesz pisać teksty ASCII. Jeśli chcesz ich użyć, musisz obsłużyć cp1252 (który obejmuje również "znak zapytania"). – Bakuriu