科学の箱

科学・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 + Slack Bot – 2

Slackのチャネルに投稿するにはChanel IDが必要。 Chanel IDは下記から取得できる。 https://api.slack.com/methods/channels.list/test …

no image

requests.exceptions.SSLError: HTTPSConnectionPoolの対応方法

エラー raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host=&#8217 …

no image

pythonでsha3をつかう

pip install sha3だと何かがダウンロードされるが下記のエラーが表示される。 c:\users\usera\appdata\local\temp\pip-install-1v_qtdxo\ …

no image

kaggle Titanic Tutorial – 7

さて今回はAgeを補完してから、元の分布と比べてみる。 def fill_age(row): condition = ( (d_train_g_m[‘Sex’] == row[‘Sex’]) &amp …

no image

pandaのチュートリアル

pandaを利用すればdata frameに関連する操作はすべて実行できる。この辺のチュートリアルというか、何かまとめたドキュメントは何か調べてみた。 https://www.dataquest.io …

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

side bar top



アーカイブ

カテゴリー