<jupyter_start><jupyter_text>NLP using NLTK<jupyter_code>import nltk
sentence1 = """At eight o'clock on Thursday morning"""
sentence1
sentence2 = """At eight o'clock on Thursday morning ... Arthur didn't feel very good."""
sentence2
tokens = nltk.word_tokenize(sentence2)
tokens
tagged = nltk.pos_tag(tokens)
tagged[0:6]
tokens
entities = nltk.chunk.ne_chunk(tagged)
entities
from nltk.corpus import treebank
t = treebank.parsed_sents('wsj_0001.mrg')[0]
t.draw()
t
entities = treebank.parsed_sents('wsj_0001.mrg')[0]
entities.draw()
entities<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12609457092819615, 'fraction_numerical': 0.0297723292469352, 'mean_word_length': 7.171428571428572, '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': '592015', 'license': 'MIT', 'n_tokens_mistral': 227, 'n_tokens_neox': 218, 'n_words': 47, 'path': 'project-nlp-nltk/nlp - nltk.ipynb', 'repo_name': 'langsari/ftu-artificial-intelligence', 'size': '571'}