Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to de-normalize text in Python?

Tags:

python

text

nlp

I am currently working on a Python project using text semantic to match similarities. At the end, my goal is to have a dataset column where all my interesting words are in order to be searched in by a dumb searchbar.

Currently I have in a column my original text and my normalized text. Is there a way to create all denormalized forms of each word (or at least for each noun) ?

like image 513
Lefloch Had Avatar asked Jul 22 '26 22:07

Lefloch Had


1 Answers

I understand that you mean to generate all possible inflexions of an English word. For that, you may use LemmInflect as follows:

from lemminflect import getAllInflections

> getInflection('watch', tag='VBD')
('watched',)

> getAllInflections('watch')
{'NN': ('watch',), 'NNS': ('watches', 'watch'), 'VB': ('watch',), 'VBD': ('watched',), 'VBG': ('watching',), 'VBZ': ('watches',),  'VBP': ('watch',)}

Update: for French, you can use inflecteur:

from inflecteur import inflecteur
inflecteur = inflecteur()
inflecteur.load_dict()
inflecteur.get_word_form('pris')
like image 61
noe Avatar answered Jul 25 '26 14:07

noe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!