"""
32. 動詞の原形
動詞の原形をすべて抽出せよ
[[{'surface': '', 'base': '*', 'pos': 'BOS/EOS', 'pos1': '*'},
{'surface': '一', 'base': '一', 'pos': '名詞', 'pos1': '数'},
{'surface': '', 'base': '*', 'pos': 'BOS/EOS', 'pos1': '*'}],
[{'surface': '', 'base': '*', 'pos': 'BOS/EOS', 'pos1': '*'},
{'surface': '吾輩', 'base': '吾輩', 'pos': '名詞', 'pos1': '代名詞'},
{'surface': 'は', 'base': 'は', 'pos': '助詞', 'pos1': '係助詞'},
{'surface': '猫', 'base': '猫', 'pos': '名詞', 'pos1': '一般'},
{'surface': 'で', 'base': 'だ', 'pos': '助動詞', 'pos1': '*'},
{'surface': 'ある', 'base': 'ある', 'pos': '助動詞', 'pos1': '*'},
{'surface': '。', 'base': '。', 'pos': '記号', 'pos1': '句点'},
{'surface': '', 'base': '*', 'pos': 'BOS/EOS', 'pos1': '*'}],
"""
import itertools
from typing import List
import utils
def get_verb(sentence: List[dict]) -> List[str, str]:
result = []
for word in sentence:
if word["pos"] == "動詞":
result.append(word["base"])
return result
data = utils.read_json("30_neko_mecab.json")
verbs = [get_verb(sentence) for sentence in data if get_verb(sentence)]
# [['生れる', 'つく'], ['する', '泣く', 'する', 'いる'], ['始める', '見る'], ['聞く'], ['捕える', '煮る', '食う']]
flat = list(itertools.chain(*verbs))
# ['生れる', 'つく', 'する', '泣く', 'する']
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme