科学の箱

科学・IT・登山の話題

Python

janomeで品詞を解析する

投稿日:

 


import sys
import os
from glob import glob
from janome.tokenizer import Tokenizer

def main():

t = Tokenizer()

print('Target Directory:' + os.path.join(input_dir, '*'))

for path in glob(os.path.join(input_dir, 'ja*')):
  print('Processing {0}...'.format(path), file=sys.stderr)
  with open(path, encoding='utf-8') as file:
    txt = file.read()
    for token in t.tokenize(txt, stream=True):
      print("----" + str(token))
      print(token.part_of_speech)

if __name__=='__main__':
  main()

メタ情報

inarticle



メタ情報

inarticle



-Python

執筆者:


comment

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

関連記事

no image

python virtualenvの使い方

pip3 install virtualenv virtualenv myenv myenv/Scripts/activate Related posts:グリッドサーチPythonでMicrosof …

no image

データ分析で理解しておくべきPythonのデータ構造

Pythonでデータ分析を行う際には基本のデータ構造を理解しておく必要がある。 scikit-learnなどのフレームワークは特定のデータ構造を入力とすることを前提にしている。用意したデータがフレーム …

no image

GCP google translatorの利用

こちらが詳しい https://cloud.google.com/translate/docs/reference/libraries#client-libraries-usage-python &n …

no image

kaggle Titanic Tutorial – 3

DecitionTreeのパラメータを調整する。 まずはMaxDepthから from sklearn.model_selection import LeaveOneOut from sklearn. …

no image

django install

まずはdjangoをインストールする pip install django   Versionを確認する python -m django –version はじめてのプロジェク …

2018年10月
« 9月   11月 »
1234567
891011121314
15161718192021
22232425262728
293031  

side bar top



アーカイブ

カテゴリー