2016-03-27 61 views
0

我做了一個語料庫abc。而我無法上傳在python如何使用我在python中創建的語料庫?

我所面臨的問題:

1)我應該把自建語料庫在所有預生成語料庫現在的位置?

1.A)如果是這樣,爲什麼我不能夠使用這個命令:(我們說的位置是 '位置')

abc = nltk.data.find('LOCATION\abc')

1.B)事實上,

from nltk import abc 

引發此錯誤

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: cannot import name abc 

2)什麼是其他方式,我可以上傳我創建的語料庫?

+0

請概述「不工作」是什麼意思。 – flaschbier

+0

回溯(最近通話最後一個): 文件「」,1號線,在 導入錯誤:無法導入名爲abc – user3771993

+0

主要是,想知道如何上傳我創建 – user3771993

回答

0

我認爲你正在尋找this other question的第一個或第二個答案。

無論如何,這是一個快速的方法來做到這一點:

import nltk 
from nltk.corpus import PlaintextCorpusReader 

corpus_root = './' 
newcorpus = PlaintextCorpusReader(corpus_root, '.*') # Files you want to add 
newcorpus.words('file-1.txt') 

沒有,把你自己的語料庫在NLTK的數據目錄似乎,而不是一個絕妙的主意。不是特別的原因,只是爲了保持你的數據獨立於工具包中的內容。

相關問題