
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
compromise-numbers
Advanced tools
npm install compromise-numbers
const nlp = require('compromise')
nlp.extend(require('compromise-numbers'))
let doc = nlp('I’d like to request seventeen dollars for a push broom rebristling')
doc.numbers().debug()
// 17
1/3rd
five
or fifth
5
or 5th
fifth
or 5th
five
or 5
20mins
-> 20 mins
if a number is changed within a sentence, attempts are made at sentence-agreement - in both a leading determiner, and the plurality of a following noun. This is done safely, but it may have sneaky or unintended effects for some applications.
money, fractions, and percentages will be returned and work fine in .numbers()
, but can be isolated with .money()
, .fractions()
and .percentages()
.fractions() will parse things like '1/3', 'one out of three', and 'one third'.
it will not pluck the fraction from the end of a number, like 'six and one third'. 'one third' will still have a #Fraction tag.
Things can get pretty crazy - and there are some human-ambiguous fractions like 'five hundred thousandths'. In these cases it tries its best.
Attempts are also made to avoid conversational fractions, like 'half time show' or dates like '3rd quarter 2020'.
$
is USD, £
is GBP, ₩
is South Korean, and 'kr'
is Swedish Krona.Configuring this should be possible in future versions.
nlp('five cents').money().get(0)
will return 0.05
(like it should), but .numbers().get()
will return 5
. This is a tricky thing that we should solve, somehow.times like 5pm
are parsed and handled by compromise-dates and are not returned by .numbers()
.
particularly, #Year
tags are applied to numbers in a delicate way.
compromise-numbers uses the period decimal point and supports comma as a thousands-seperator. Some european or latin-american number formats like comma-decimals, or space-separated-thousands do not parse properly.
attempts are made to ignore phone-numbers, postal-codes and credit-card numbers from .numbers()
results, but there may be numbers used in other ways that are not accounted for.
work in progress!
MIT
FAQs
plugin for nlp-compromise
The npm package compromise-numbers receives a total of 1,131 weekly downloads. As such, compromise-numbers popularity was classified as popular.
We found that compromise-numbers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.