簡體   English   中英

python中法語單詞的復數到單數

[英]Plural to singular of french words in python

我有一個單詞列表,我試圖在 python 中將復數單詞轉換為單數,然后刪除重復項。 我就是這樣做的:

import spacy
nlp = spacy.load('fr_core_news_md')

words = ['animaux', 'poule', 'adresse', 'animal', 'janvier', 'poules']
clean_words = []

for word in words:
    doc = nlp(word)
    
for token in doc:
    clean_words.append(token.lemma_)
    
clean_words = list(set(clean_words))

這是 output:

['animal', 'janvier', 'poule', 'adresse']

它運作良好,但我的問題是“fr_core_news_md”加載時間太長了,所以我想知道是否有其他方法可以做到這一點?

您嘗試執行的任務稱為詞形還原,它不僅僅是將復數轉換為單數,它還消除了它的屈曲。 它返回一個單詞的規范版本,例如動詞的不定式。

如果您想使用 spacy,您可以使用disable參數使其加載更快。 例如spacy.load('fr_core_news_md', disable=['parser', 'textcat', 'ner', 'tagger'])

或者,您使用treetagger ,它有點難以安裝,但效果很好。 FrenchLefffLemmatizer

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM