<jupyter_start><jupyter_text>3.1.2 Cabochaの利用<jupyter_code># リスト 3.1.1 
#  PythonからCabchaの呼び出し

# Cabochaの利用 (Tokenの取得)
from cabocha.analyzer import CaboChaAnalyzer
analyzer = CaboChaAnalyzer()
tree = analyzer.parse('今日はいい天気ですね')
for chunk in tree:
    for token in chunk:
        print(token)
# リスト 3.1.2
# Cabochaの利用 (チャンクを先頭からたどる)

chunks = tree.chunks
start_chunk = chunks[0]
print('開始チャンク: ', start_chunk)
next_chunk = start_chunk.next_link
print('次のチャンク: ', next_chunk)
# リスト 3.1.3
# Cabochaの利用 (チャンクを最後からたどる)

end_chunk = chunks[-1]
print('最終チャンク: ', end_chunk)
prev_chunk = end_chunk.prev_links
print('一つ前のチャンク: ', prev_chunk)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12349397590361445, 'fraction_numerical': 0.02108433734939759, 'mean_word_length': 5.785714285714286, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '211697', 'license': 'Apache-2.0', 'n_tokens_mistral': 334, 'n_tokens_neox': 317, 'n_words': 50, 'path': 'samples/ch03-01/ch03-01-01.ipynb', 'repo_name': 'TaikiOkamoto/sample_code', 'size': '664'}