Comments (5)
hey Tom, yep - if I remember we still do some of this number-range stuff out of the box, but shied-away from some of it that resembled algebra or subtraction. This is a real doozie, and I agree it's a cool thing to opt-in to, and we should support any unambiguous 'and a half' stuff as much as we can.
You can see some of the fractions tests we pass, and avoid for this here, PRs welcome if you can improve on it, in any way.
ps i enjoyed your blog.
cheers
from compromise.
hey Tom, apologies for the delay.
yeah, there's an ugly way:
let doc = nlp('2 to 3 people')
let { before, prep } = doc.match('[<before>#Value] [<prep>to] #Value').groups()
before.post('') //remove '2' whitespace
doc.match(prep).replaceWith('-').post('') //remove '-' whitespace
console.log(doc.text()) //2-3 people
in short, some of this is weird. You may benefit from using replace() with some term methods like @hasDash
or @hasHyphen
This nlp('15-ounce (15-ounce)').debug()
one is a doozie. Haven't got it yet, but will.
from compromise.
hey @track0x1 , this is fixed in 14.12.0
:
let doc = nlp('10-ounce (12-ounce)')
doc.terms().length // 4
cheers
from compromise.
@spencermountain Thank you Spencer! I just realized something that looks like a bug. When 15-ounce
is wrapped in parentheses it's tagged as a single term and resultantly has the wrong tags.
> nlp('15-ounce (15-ounce)').debug()
┌─────────
│ '15' - Value, Cardinal, NumericValue, Hyphenated
│ 'ounce' - Noun, Unit, Singular, Hyphenated
│ '15-ounce' - Infinitive, Verb, PresentTense
sidebar: is there a way we can convert verbose number ranges (2 to 3) to hyphenated number ranges (2-3)? that would enable me to tap into the same #NumberRange tag for a match.
> nlp('2 to 3 people').debug()
┌─────────
│ '2' - Value, Cardinal, NumericValue
│ 'to' - Conjunction
│ '3' - Value, Cardinal, NumericValue
│ 'people' - Noun, Plural, Actor
> nlp('2-3 people').debug()
┌─────────
│ '[2]' - Value, Cardinal, NumericValue, NumberRange
│ '[to]' - Conjunction, NumberRange
│ '[3]' - Value, Cardinal, NumericValue, NumberRange
│ 'people' - Noun, Plural, Actor
edit: also happy to split these concerns into separate issues/discussions if you prefer
from compromise.
hey @track0x1 , this is fixed in
14.12.0
:let doc = nlp('10-ounce (12-ounce)') doc.terms().length // 4cheers
You're the best! Thank you
from compromise.
Related Issues (20)
- Apostrophe "s" disambiguation issue with search query style sentences HOT 7
- Query: Does Compromise.js compile RegExes from match-syntax? HOT 1
- Get .terms() but keep hyphenated strings (similar to .hyphenated() ) HOT 1
- Using .freeze() in nlp.plugin()? HOT 11
- JSON Speed HOT 2
- Feature request: Logical operations in match HOT 2
- [Issue]: Various common nouns tagged as proper noun. HOT 6
- True Casing HOT 10
- [Improvements]: Add .toLowerCase() API to various functions. HOT 1
- [Issue]: Gov Rule & Possible Other's Needs Improved. HOT 5
- [Issue]: "My favorite time of the year" in .nouns() response HOT 3
- `.prepend()` removes frozen tags for acronyms HOT 2
- Improve TypeScript DX by reducing usage of "any" HOT 1
- NFD form combining characters not picked up as part of word HOT 3
- Feature: .slashes() tokenize transform HOT 6
- Geedy tag matching and punctuation HOT 2
- [Feature Request]: Flesch–Kincaid Function HOT 6
- "to" is a preposition and not a conjuction HOT 1
- Verb is mistakenly parsed as a noun. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compromise.