chatbot_ner icon indicating copy to clipboard operation
chatbot_ner copied to clipboard

Issue with accessing of date detector

Open ellurunaresh opened this issue 7 years ago • 2 comments

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)

ellurunaresh avatar Apr 02 '19 06:04 ellurunaresh

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.

chiragjn avatar Apr 02 '19 07:04 chiragjn

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")

ellurunaresh avatar Apr 02 '19 08:04 ellurunaresh