2017-06-09 30 views
7

Cụm từ NLTK không có cụm từ "okay", "ok", "Okay"?từ nltk corpus không chứa "okay"?

> from nltk.corpus import words 
> words.words().__contains__("check") 
> True 

> words.words().__contains__("okay") 
> False 

> len(words.words()) 
> 236736 

Mọi ý tưởng tại sao?

+0

Heh, TIL 'zymolysis',' okupukupu' và rất nhiều từ mơ hồ nằm trong kho trong khi 'okay' thì không. Bạn có lẽ nên hỏi nó trong [nltk github] (https://github.com/nltk/nltk) hoặc sử dụng một kho văn bản khác nhưng tốt. – umutto

+0

Thông tin chi tiết về nội dung của một số kho văn bản cụ thể không phải là câu hỏi lập trình, ngay cả khi ai đó có thể trả lời nó, nó khá rõ ràng ngoài chủ đề. Có vẻ hợp lý hơn khi hỏi những người bảo quản. – pvg

+0

Tôi đồng ý với @kindall –

Trả lời

7

TL; DR

from nltk.corpus import words 
from nltk.corpus import wordnet 

manywords = words.words() + wordnet.words() 

Trong dài

Từ docs, các nltk.corpus.words là những từ một danh sách các từ từ "http://en.wikipedia.org/wiki/Words_(Unix)

nào trong Unix, bạn có thể làm:

ls /usr/share/dict/ 

Và đọc README:

$ cd /usr/share/dict/ 
/usr/share/dict$ cat README 
# @(#)README 8.1 (Berkeley) 6/5/93 
# $FreeBSD$ 

WEB ---- (introduction provided by [email protected]) ------------------------- 

Welcome to web2 (Webster's Second International) all 234,936 words worth. 
The 1934 copyright has lapsed, according to the supplier. The 
supplemental 'web2a' list contains hyphenated terms as well as assorted 
noun and adverbial phrases. The wordlist makes a dandy 'grep' victim. 

    -- James A. Woods {ihnp4,hplabs}!ames!jaw (or [email protected]) 

Country names are stored in the file /usr/share/misc/iso3166. 


FreeBSD Maintenance Notes --------------------------------------------- 

Note that FreeBSD is not maintaining a historical document, we're 
maintaining a list of current [American] English spellings. 

A few words have been removed because their spellings have depreciated. 
This list of words includes: 
    corelation (and its derivatives) "correlation" is the preferred spelling 
    freen    typographical error in original file 
    freend    archaic spelling no longer in use; 
        masks common typo in modern text 

-- 

A list of technical terms has been added in the file 'freebsd'. This 
word list contains FreeBSD/Unix lexicon that is used by the system 
documentation. It makes a great ispell(1) personal dictionary to 
supplement the standard English language dictionary. 

Kể từ đó là một danh sách cố định của 234.936, có ràng buộc để được lời rằng không tồn tại trong danh sách đó.

Nếu bạn cần mở rộng danh sách từ, bạn có thể thêm vào danh sách bằng các từ từ WordNet sử dụng nltk.corpus.wordnet.words().

Có thể, tất cả những gì bạn cần là một văn bản đủ lớn văn bản, ví dụ: Wikipedia đổ và sau đó tokenize nó và trích xuất tất cả các từ duy nhất.

+2

'Có một kho chứa từ bạn đang tìm kiếm' không thực sự trả lời 'tại sao tập dữ liệu này không bao gồm từ này'. Cũng không rõ ràng cách thức 'TL; DR' có thể áp dụng hoặc giải thích được. – pvg

+0

@alvas Cảm ơn vì công việc xung quanh. Đây là những gì tôi đã làm, cùng với việc sử dụng một từ điển tùy chỉnh. Vì vậy, ba từ điển trong tổng số. Giải thích thú vị – MonsieurBeilto

+2

từ nltk.corpus nhập wordnet như wn? –

Các vấn đề liên quan