Comments (6)
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.
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.
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.
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.
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.
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)
- specify certain date for calendar HOT 1
- Interpreting backwards instead of forwards HOT 1
- Is it work if there are more than one dates in text? HOT 2
- "This" at the end of a time string sets time to "now"
- importing is failed HOT 2
- parsedatetime.Calendar() is broken in Python 2.7 HOT 3
- Several typos in the NL file (native speaker).
- AttributeError: 'module' object has no attribute 'Locale' HOT 2
- 'XX hours YY min ago' gives incorrect output HOT 1
- how to support Chinese Language? HOT 2
- Wrong Parsing on XMP-datetime
- tzinfo flag doesn't appear to do anything
- FAIL: testDate3ConfusedHourAndYear (tests.TestComplexDateTimes.test) HOT 1
- "this afternoon" doesn't respect sourceTime in Calendar.parse()
- Comparing parsedatetime to dateparser? HOT 1
- Interpret "at" as an indicator for time
- Support for preceding 'previous' modifiers
- recognize UTC timestamps
- testNextMonth fails on February 29th
- Add type annotations
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 parsedatetime.