Exemplo n.º 1
0
thesaurus_path = '../corpus/thesaurus/thesaurus.txt'
IDF_path = '../auto/IDF.index'
tfidf_DB_path = '../auto/TFIDF_vectors_DB'

base_name = os.path.basename(text_path)  # A.text
root = os.path.splitext(base_name)[0]  # A

#-------------------------------------------------------------------------------------
#                       main
#-------------------------------------------------------------------------------------

PREPROCESSOR = Preprocessor(thesaurus_path)  # シソーラス・パスを渡さなければ置換をしません。
print('前処理を行います')
PREPROCESSOR.load_text([text_path])
whitelist = PREPROCESSOR.investigate_whitelist(thesaurus_path)
print('保存します')
PREPROCESSOR.save(auto_text_path)
PARSER = Parser()
print('かかり受け解析を行います..')
PARSER.t2f([auto_text_path + '/' + root + '.text'],
           kytea_model=kytea_path,
           eda_model=eda_path)
print('結果を保存します')
PARSER.save(tree_path)  # かかり受け解析したものをファイルに保存
print("Indexを読み込みます...")
VECTORIZER = Vectorizer(index_path, t=1, list=whitelist)  # Indexの読み込み
print('Treeを読み込みます')
vectors = VECTORIZER.get_vector([tree_path + '/' + root + '.eda'],
                                filter=3)  # ベクトルを生成
print(vectors)