Giter Club home page Giter Club logo

Comments (5)

spencermountain avatar spencermountain commented on June 2, 2024 1

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.

spencermountain avatar spencermountain commented on June 2, 2024 1

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.

spencermountain avatar spencermountain commented on June 2, 2024 1

hey @track0x1 , this is fixed in 14.12.0:

let doc = nlp('10-ounce (12-ounce)')
doc.terms().length // 4

cheers

from compromise.

track0x1 avatar track0x1 commented on June 2, 2024

@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.

track0x1 avatar track0x1 commented on June 2, 2024

hey @track0x1 , this is fixed in 14.12.0:

let doc = nlp('10-ounce (12-ounce)')
doc.terms().length // 4

cheers

You're the best! Thank you

from compromise.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.