akshaynagpal / w2n

Convert number words (eg. twenty one) to numeric digits (21)
http://w2n.readthedocs.io
MIT License
169 stars 78 forks source link

Replace words in a sentence #58

Open Gunni opened 3 years ago

Gunni commented 3 years ago

Hey, i would like to be able to feed this library a string, such as:

and get back, in those examples:

Is that possible?

bastie commented 3 years ago

First this module is very nice but also long time not update and so I'm sorry to recommend take a fork; over Insights => network you find working forks. The https://github.com/frootbirb fork may be interesting but I don't tested it ("-" problem perhaps).

Second the answer is: not with this module alone in generic way. You get only this numbers as return.

But if ever the number is last in your sentences try it.

The module is not a NLP library but nice to work at result from NLP. As result of NLP you have a good chance to get a right tagging as num for "One" "Hundred" "Fifteen" "Ninety-Eight" and can the result send to word_to_number. Only a chance in result often numbers are tagged as noun for example https://parts-of-speech.info and insert your text without some NLP steps before.

Gunni commented 3 years ago

Hey,

You were right, I got it working at last, after much work https://gist.github.com/Gunni/7d2e14b49d3f0483666843e31b2b358f .

The biggest problem was the normal tokenizer refused to tag random numbers, so I had to make my own tagger, and feed it tagged "number words".

I did it for all numbers from 10k to 0.

That works for my usecase, maybe it can help someone else out there...

akshaynagpal commented 3 years ago

Hi @Gunni , I have been super busy with other commitments and plan on updating the package as soon as I get some free time. Thanks for understanding.