-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Suggestion]: Improvements on currency parser & rules. #1037
Comments
Leaving this here for self - WIP: function extractCurrencys(str) {
let doc = nlp(str).money().json();
let currencies = []
for(let item in doc){
let currency = doc[item]
let unit = currency?.number?.unit; // we need to replace units with only (dollars/cents, exchanges like USD etc...)
const text = currency?.text;
if(unit && !nlp(currency.number.unit).has("#Currency")){
unit = null;
}
if(unit && text){
currencies.push({text,unit})
}
if(!unit && text){
currencies.push({text,unit:null})
}
}
return currencies
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The currency parser seems to need some work. Things like ("Five cents") or ("5 dollars") just return "5"...
Plus we should be adding rules for all things like "(one|five|ten) (dollar|dollars) bill".
That said - throwing this here! (Thinking this should be the new .get() ) etc...
If you want to hack on this alone - you're more than welcome. Or you want to work on it together. More than fine.
The text was updated successfully, but these errors were encountered: