2017-12-08 5 views
1

xml에서 단순히 corpus를 읽고 모두 추가하기 만하면됩니다. 나는 baby-bnc (2553)로 시도해보고 성공적으로 일반 텍스트 파일로 변환했지만 full-bnc (2554) 또는 샘플러 (2551)를 사용하면이 오류가 계속 표시됩니다. ValueError : concat 하나의 물건!Python BNCCorpusReader가 전체 bnc corpus와 작동하지 않습니다.

import nltk.corpus.reader.bnc as cor  
a=cor.BNCCorpusReader(root=r'BNC\2553\2553\download\Texts',fileids=r'[a-z]{3}/\w*\.xml') 
len(a.sents()) 
with open("2553.txt",'w',encoding='utf-8') as nf: 
    for s in a.sents(): 
     nf.write(' '.join(s)) 
    pass 

이 그것은 다음과 같이 표시하도록되어

a=cor.BNCCorpusReader(root=r'BNC\2553\2553\download\Texts',fileids=r'[a-z]{3}/\w*\.xml')  
In[18]: len(a.sents()) 
Out[18]: 280851 

을 (아기 시체와 함께 잘 작동)하지만 내가 사용하는 데 필요한 전체 시체와 함께, 결과는 항상 오류입니다.

b=cor.BNCCorpusReader(root=r'BNC\2554\Texts',fileids=r'[a-z]{3}/\w*\.xml') 
In[18]: len(b.sents())  
ValueError: concat() expects at least one object! 

다운로드 할 때 문제가있어 다른 컴퓨터에 여러 번 다운로드했지만 여전히 작동하지 않는다고 생각합니다.

나는 도움을 줄 필사적으로 찾고 있습니다.

답변

0

다른 폴더 구조를 가지고 있습니다. 이걸 사용해보십시오 fileids = r '[A-K]/\ w */\ w * .xml'

관련 문제