Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
448 B
1
Indexable
Never
import spacy

# Load the Spacy model for English language
nlp = spacy.load('en_core_web_sm')

def lemmatize_word(sentence):
    # Parse the sentence using Spacy
    doc = nlp(sentence)
    
    # Lemmatize each word in the sentence
    lemmatized_words = [token.lemma_ for token in doc]
    
    # Join back the lemmatized words into a sentence
    lemmatized_sentence = ' '.join(lemmatized_words)
    
    return lemmatized_sentence