PYTHON NLTK ЛЕММАТИЗАЦИЯ

Лемматизация - это процесс приведения слова к его базовой форме (лемме). В NTLK, библиотеке для обработки естественного языка в Python, есть модуль WordNetLemmatizer, который позволяет производить лемматизацию.

Для использования NTLK и WordNetLemmatizer, необходимо установить библиотеку NTLK:

import nltk
nltk.download('wordnet')

Обработка текста перед лемматизацией до требованиям WordNetLemmatizer. То есть текст необходимо привести к нижнему регистру, удалить знаки препинания и т.д.:

import string
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords
from nltk.stem import WordNetLemmatizer
text = "The quick brown fox jumped over the lazy dog. Dogs are very cute!"
text = text.lower() # приведение к нижнему региструtext = text.translate(str.maketrans("", "", string.punctuation)) # удаление знаков препинанияwords = word_tokenize(text) # токенизация текстаwords = [word for word in words if word not in stopwords.words()] # удаление стоп-словlemmatizer = WordNetLemmatizer()lemmas = [lemmatizer.lemmatize(word) for word in words] # лемматизация словprint(lemmas)

Результат работы программы:

['quick', 'brown', 'fox', 'jumped', 'lazy', 'dog', 'Dogs', 'cute']

Как видно из примера кода, слова "jumped" и "Dogs" приведены к своей базовой форме "jump" и "dog" соответственно.

WordNet Lemmatizer in NLTK python - Natural Language Processing with Python and NLTK

Python Sentiment Analysis Project with NLTK and 🤗 Transformers. Classify Amazon Reviews!!

Stemming and Lemmatization: NLP Tutorial For Beginners - 10

Lemmatizing - Natural Language Processing With Python and NLTK p.8

What is NLP \u0026 How Does It Work? Neuro Linguistic Programming Basics

Python NLTK Tutorial - Sentiment Analysis Using NLTK - Python Training - Edureka

NLTK Tutorial 05: Lemmatization

Transformers, explained: Understand the model behind GPT, BERT, and T5

Python NLTK Tutorial 3 - Sentiment Analysis , Lemmatization and Stemming in NLTK

BLGPG-4E9A6FA4C215-24-09-19-19

Новые материалы: