Giter Club home page Giter Club logo

Comments (6)

bear avatar bear commented on August 18, 2024

probably - looking at the code we could introduce a list of strings to check at around

https://github.com/bear/parsedatetime/blob/master/parsedatetime/__init__.py#L1672

that is where "$300" becomes "3:00" and the chunk1 variable contains "$" - so yea, if chunk1 was found in the exception list then fail the match and proceed as if nothing happend.

from parsedatetime.

Rob1080 avatar Rob1080 commented on August 18, 2024

It seems that at https://github.com/bear/parsedatetime/blob/master/parsedatetime/__init__.py#L1672
the value that comes through from the regex is 300 (without the $), so not particularly easy to filter it out at that point.

from parsedatetime.

bear avatar bear commented on August 18, 2024

what version are you using? I did a test parse for "$300" and this is the debug output:

DEBUG:parsedatetime:parse()
DEBUG:parsedatetime:parse (top of loop): [$300][]
DEBUG:parsedatetime:parse 1 [][][]
DEBUG:parsedatetime:parse 2 [][][]
DEBUG:parsedatetime:parse 3 [][][]
DEBUG:parsedatetime:parse 4 [][][]
DEBUG:parsedatetime:parse 5 [][][]
DEBUG:parsedatetime:parse 6 [][][]
DEBUG:parsedatetime:parse 7 [][][]
DEBUG:parsedatetime:parse 8 [][][]
DEBUG:parsedatetime:parse 9 [][][]
DEBUG:parsedatetime:parse A [][][]
DEBUG:parsedatetime:parse (bottom) [$ ][3:00][$][]
DEBUG:parsedatetime:weekday False, dateStd False, dateStr False, time True, timeStr False, meridian False
DEBUG:parsedatetime:dayStr False, modifier False, modifier2 False, units False, qunits False
DEBUG:parsedatetime:_evalString(3:00, None)

the debug line for "parse (bottom)" shows that chunk1 has the value of "$" at that point

from parsedatetime.

Rob1080 avatar Rob1080 commented on August 18, 2024

I'm running from head.
Debug for me is as follows. Have I possibly setup something wrong?

DEBUG:parsedatetime:parse()
DEBUG:parsedatetime:parse (top of loop): [300][]
DEBUG:parsedatetime:parse 1 [][][]
DEBUG:parsedatetime:parse 2 [][][]
DEBUG:parsedatetime:parse 3 [][][]
DEBUG:parsedatetime:parse 4 [][][]
DEBUG:parsedatetime:parse 5 [][][]
DEBUG:parsedatetime:parse 6 [][][]
DEBUG:parsedatetime:parse 7 [][][]
DEBUG:parsedatetime:parse 8 [][][]
DEBUG:parsedatetime:parse 9 [][][]
DEBUG:parsedatetime:parse A [][][]
DEBUG:parsedatetime:parse (bottom) [ ][3:00][][]
DEBUG:parsedatetime:weekday False, dateStd False, dateStr False, time True, timeStr False, meridian False
DEBUG:parsedatetime:dayStr False, modifier False, modifier2 False, units False, qunits False
DEBUG:parsedatetime:_evalString(3:00, None)
DEBUG:parsedatetime:attempt to parse as rfc822 - None
DEBUG:parsedatetime:parse (top of loop): [ ][]
DEBUG:parsedatetime:parse 1 [][][]
DEBUG:parsedatetime:parse 2 [][][]
DEBUG:parsedatetime:parse 3 [][][]
DEBUG:parsedatetime:parse 4 [][][]

DEBUG:parsedatetime:parse 5 [][][]
DEBUG:parsedatetime:parse 6 [][][]
DEBUG:parsedatetime:parse 7 [][][]
DEBUG:parsedatetime:parse 8 [][][]
DEBUG:parsedatetime:parse 9 [][][]
DEBUG:parsedatetime:parse A [][][]
DEBUG:parsedatetime:parse (bottom) [][][][]
DEBUG:parsedatetime:weekday False, dateStd False, dateStr False, time False, timeStr False, meridian False
DEBUG:parsedatetime:dayStr False, modifier False, modifier2 False, units False, qunits False
DEBUG:parsedatetime:parse() return dateFlag 0 timeFlag 2 totalTime (2014, 10, 29, 3, 0, 0, 2, 302, 0)

Code running from testNlp class:
result = self.cal.nlp("$300") #dollar amounts shouldn't interfere with recognition self.assertTrue(result [0][4] != "300")

from parsedatetime.

bear avatar bear commented on August 18, 2024

ah - your running with nlp() and I ran with parse() - look at the output difference for the "(top of loop)" debug line.

i'll rerun that test in a bit and see why it's different.

from parsedatetime.

Rob1080 avatar Rob1080 commented on August 18, 2024

Cool, thanks. As I said, not sure it's essential. One could always pre-parse text for a given word e.g. $300 and strip that before sending to nlp for parsing.

from parsedatetime.

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.