“NLTK in Python” Code-Antworten

NLTK in Python

pip install nltk
Attractive Anteater

NLTK Python

>>> import nltk
>>> sentence = """At eight o'clock on Thursday morning
... Arthur didn't feel very good."""
>>> tokens = nltk.word_tokenize(sentence)
>>> tokens
['At', 'eight', "o'clock", 'on', 'Thursday', 'morning',
'Arthur', 'did', "n't", 'feel', 'very', 'good', '.']
>>> tagged = nltk.pos_tag(tokens)
>>> tagged[0:6]
[('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'),
('Thursday', 'NNP'), ('morning', 'NN')]
hadi

NLTK Python

pip install nltk
import nltk
nltk.download()
Hassan

So importieren Sie NLTK

import nltk
from nltk.stem.lancaster import LancasterStemmer
stemmer = LancasterStemmer()


Handsome Hornet

NLTK in Python

from nltk.stem import PorterStemmer
from nltk.tokenize import sent_tokenize, word_tokenize
sentence="Hello, Did you enjoy the party? Everybody enjoyed the party"
words = word_tokenize(sentence)
ps = PorterStemmer()
for w in words:
	rootWord=ps.stem(w)
	print(rootWord)
Manisha Gupta

Ähnliche Antworten wie “NLTK in Python”

Fragen ähnlich wie “NLTK in Python”

Weitere verwandte Antworten zu “NLTK in Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen