> Every page of the ganymede website is listed in https://eugo.io/docs/ganymede/llms.txt.

# NLTK

> NLTK: A suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing

Web page: https://eugo.io/docs/ganymede/demo_notebooks/data_processing/nltk/
Notebook: https://eugo.io/docs/ganymede/demo_notebooks/data_processing/nltk/nltk.ipynb (source: https://github.com/eugo-inc/ganymede/blob/main/demo_notebooks/data_processing/nltk.ipynb)

Description:
- A suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing

Resources:
- [GitHub] https://github.com/nltk/nltk
- [Docs] https://www.nltk.org/
- [Examples] https://www.nltk.org/howto.html

## Example 1

Example utility

```python
from nltk.util import *

print_string("This is a long string, therefore it should break", 25)
```

## Example 2

Create a tree

```python
from nltk.tree import Tree

tree = Tree(5,[Tree(4, [Tree(2, [1, 3])]),
              Tree(8, [Tree(6, [7]), 9])])

for x in breadth_first(tree):
    if isinstance(x, int): 
        print(x)
    else: 
        print(x.label())
```

## Example 3

Chunking

```python
from nltk.chunk import *
from nltk.chunk.util import *
from nltk.chunk.regexp import *
from nltk import Tree

tagged_text = "[ The/DT cat/NN ] sat/VBD on/IN [ the/DT mat/NN ] [ the/DT dog/NN ] chewed/VBD ./."
gold_chunked_text = tagstr2tree(tagged_text)
unchunked_text = gold_chunked_text.flatten()
print(unchunked_text)
```

## Example 4

Parsing

```python
import pickle
import subprocess
import sys
from nltk import Nonterminal, nonterminals, Production, CFG

nt1 = Nonterminal('NP')
nt2 = Nonterminal('VP')
nt1.symbol()
```
