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

we are getting wrong output one of your example what you explained in the document named chatbot_ner/docs/api_call.md #274

Closed
prasannaonchip opened this issue Jul 4, 2019 · 4 comments

Comments

@prasannaonchip
Copy link

message = u'I want to order 2 burgers from mainland china at 3 pm '
entity_name = 'restaurant'
structured_value=None
fallback_value=None
bot_message=None
source_language='en'

from ner_v1.chatbot.entity_detection import get_text
output = get_text(message=message, entity_name=entity_name,
structured_value=structured_value,
fallback_value=fallback_value,
bot_message=bot_message,language=source_language)
print(output)

we tested the example of this by using the python shell the actual output in my system is

[{'original_text': 'mainland china', 'detection': 'message', 'language': 'en', 'entity_value': {'crf_model_verified': False, 'value': 'Mainland China', 'datastore_verified': True}}]

but in your document the output is
output:
[
{
"detection": "message",
"original_text": "2",
"entity_value": { "value": "2", "unit": null},
"language": "en"
},
{
"detection": "message",
"original_text": "3 pm",
"entity_value": { "mm": 0, "hh": 3, "nn": "pm"},
"language": "en"
}
]

Example 2:
// If today is 19th feb
input:
message = u'I have my maths exam next Saturday.'
entity_name = 'date'
structured_value = None
structured_value_verification = 0
fallback_value = None
bot_message = None

output:[
{
"detection": "message",
"original_text": "inferno",
"entity_value": {"value": {"mm":03, "yy": 2019, "dd": 02, "type": "date"}},
"language": "en"
},
]

for example 2 we are getting the output is None
why it is not working properly
please reply fast
thank in advance.

@prasannaonchip
Copy link
Author

please reply

@chiragjn
Copy link
Contributor

chiragjn commented Jul 4, 2019

The docs are somewhat wrong

If you run TextDetector with entity_name restaurant and number detector , you'll get the correct outputs

from ner_v2.detectors.numeral.number.number_detection import NumberDetector
message = u'I want to order 2 burgers from mainland china at 3 pm '
structured_value=None
fallback_value=None
restaurant_detector = TextDetector(entity_name='restaurant', source_language_script='en')
number_detector = NumberDetector(entity_name='number', language='en')
print(restaurant_detector.detect(message=message, structured_value=structured_value, fallback_value=fallback_value))
print(number_detector.detect(message=message, structured_value=structured_value, fallback_value=fallback_value))
[{'detection': 'message',
  'entity_value': {'value': u'Mainland China'},
  'language': 'en',
  'original_text': u'mainland china'}]

[{'detection': 'message',
  'entity_value': {'unit': None, 'value': '2'},
  'language': 'en',
  'original_text': u'2'},
 {'detection': 'message',
  'entity_value': {'unit': None, 'value': '3'},
  'language': 'en',
  'original_text': u'3'}]

@prasannaonchip
Copy link
Author

How to use multiple entities in python
in your documents you people are explained the one example which multiple entities in the form of list
example is
entities = ['date','time','restaurant']
message = "Reserve me a table today at 6:30pm at Mainland China and on Monday at 7:00pm at Barbeque Nation"
which is present in the document named as chatbot_ner/docs/install.md

here for this we tried this in the form of

from ner_v1.chatbot.entity_detection import get_text
from ner_v2.detectors.temporal.date.date_detection import DateAdvancedDetector
from ner_v2.detectors.temporal.time.time_detection import TimeDetector

message = "Reserve me a table today at 6:30pm at Mainland China and on Monday at 7:00pm at Barbeque Nation"
entity_name = ['date','time','restaurant']
structured_value=None
fallback_value=None
bot_message=None
source_language='en'
timezone='UTC'
past_date_referenced=False

detector = DateAdvancedDetector(entity_name=[0],language=source_language,timezone=timezone,past_date_referenced=past_date_referenced)
output_date = detector.detect(message=message, entity_name=[0],structured_value=structured_value,fallback_value=fallback_value)

detector = TimeDetector(entity_name=entity_name[1], language=source_language,timezone=timezone)
output_time = detector.detect(message=message, entity_name=entity_name[1],structured_value=structured_value,fallback_value=fallback_value)

output_res = get_text(message=message, entity_name=entity_name[2],
structured_value=structured_value,fallback_value=fallback_value,bot_message=bot_message,language=source_language)

here we are getting the error like this
Traceback (most recent call last):
File "3.py", line 33, in
fallback_value=fallback_value)
File "../ner_v2/detectors/temporal/date/date_detection.py", line 717, in detect
entity_list, original_text_list = self.detect_entity(text=text)
File "../ner_v2/detectors/temporal/date/date_detection.py", line 140, in detect_entity
date_data = self._detect_date()
File "../ner_v2/detectors/temporal/date/date_detection.py", line 161, in _detect_date
date_dict_list = self._detect_any_date()
File "../ner_v2/detectors/temporal/date/date_detection.py", line 396, in _detect_any_date
date_dict_list = self._date_dict_from_text(text=self.processed_text)
File "../ner_v2/detectors/temporal/date/date_detection.py", line 477, in _date_dict_from_text
date_list, original_list = self._date_value(text=text)
File "../ner_v2/detectors/temporal/date/date_detection.py", line 504, in _date_value
date_list, original_list = self.date_detector_object.detect_entity(text)
File "../ner_v2/detectors/temporal/date/date_detection.py", line 828, in detect_entity
self.date, self.original_date_text = self.language_date_detector.detect_date(self.processed_text)
File "../ner_v2/detectors/temporal/date/en/date_detection.py", line 117, in detect_date
date_list, original_list = self.get_exact_date(date_list, original_list)
File "../ner_v2/detectors/temporal/date/en/date_detection.py", line 174, in get_exact_date
date_list, original_list = self._gregorian_month_day_format(date_list, original_list)
File "../ner_v2/detectors/temporal/date/en/date_detection.py", line 710, in _gregorian_month_day_format
if self.now_date.month > mm:
TypeError: '>' not supported between instances of 'int' and 'NoneType'

individually time, date, text all are working fine by combining this two(by adding date and time) or(text and date) or three(combination of text ,date ,time ) is not working properly.

please reply fast
thanks in advance

@chiragjn
Copy link
Contributor

chiragjn commented Jul 9, 2019

I'll address this in #275 when I get some more time to reply. Please avoid duplicating issues.

@chiragjn chiragjn closed this as completed Jul 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants