Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with accessing of date detector #234

Open
ellurunaresh opened this issue Apr 2, 2019 · 2 comments
Open

Issue with accessing of date detector #234

ellurunaresh opened this issue Apr 2, 2019 · 2 comments

Comments

@ellurunaresh
Copy link

ellurunaresh commented Apr 2, 2019

Hi all,

I went through all the steps to install char NER. I couldn't access the DateAdvanceDetector from django shell and DateDetector doesn't have detect method.
Could you please help me out to use date detector in django

from ner_v2.detectors.temporal.date.date_detection import DateAdvanceDetector

  1. detector = DateAdvanceDetector(entity_name=entity_name, language=source_language,
    timezone=timezone,
    past_date_referenced=past_date_referenced)

from ner_v2.detectors.temporal.date.date_detection import DateDetector
2.) detector = DateDetector(entity_name=entity_name, language=source_language,
timezone=timezone,
past_date_referenced=past_date_referenced)
output = detector.detect(message=message, entity_name=entity_name,
structured_value=structured_value,
fallback_value=fallback_value)

@chiragjn
Copy link
Contributor

chiragjn commented Apr 2, 2019

Hello, can you please post your traceback error ? I think the error is mostly because of a typo. It is DateAdvancedDetector not DateAdvanceDetector

You can use DateAdvancedDetector via code as follows.

from ner_v2.detectors.temporal.date.date_detection import DateAdvancedDetector
date_detector = DateAdvancedDetector(entity_name='date', language='en', timezone='Asia/Kolkata')
date_detector.detect('5th March')

which gives

[{'detection': 'message',
  'entity_value': {'end_range': False,
   'from': False,
   'normal': True,
   'start_range': False,
   'to': False,
   'value': {'dd': 5, 'mm': 3, 'type': 'date', 'yy': 2020}},
  'language': 'en',
  'original_text': '5th march'}]

We would not recommend to use DateDetector directly but if you want you can call .detect_entity() on DateDetector instance. Currently we are changing the API to remove the DateAdvanceDetector and directly use DateDetector.

@ellurunaresh
Copy link
Author

It worked. Thanks :)
I was getting null for this sentence in date detector. Is it past/future references couldn't parse?

date_detector.detect("I am traveling next week")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants