Skip to content

Commit

Permalink
Merge pull request #229 from hellohaptik/api_to_get_entity_unique_values
Browse files Browse the repository at this point in the history
Added new url call to read unique values for text entity
  • Loading branch information
amansrivastava17 authored Mar 20, 2019
2 parents 73bf290 + e3b3b51 commit 5979fd3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion chatbot_ner/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@
url(r'^entities/train_crf_model', external_api.train_crf_model),

url(r'^entities/languages/v1/(?P<entity_name>.+)$', external_api.entity_language_view),
url(r'^entities/data/v1/(?P<entity_name>.+)$', external_api.entity_data_view)
url(r'^entities/data/v1/(?P<entity_name>.+)$', external_api.entity_data_view),

# Read unique values for text entity
url(r'^entities/values/v1/(?P<entity_name>.+)$', external_api.read_unique_values_for_text_entity),

]
16 changes: 16 additions & 0 deletions external_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,19 @@ def entity_data_view(request, entity_name):

else:
raise APIHandlerException("{0} is not allowed.".format(request.method))


@external_api_response_wrapper
def read_unique_values_for_text_entity(request, entity_name):
"""
API call to View unique values for text entity.
"""
if request.method == 'GET':
try:
return dictionary_utils.get_entity_unique_values(entity_name=entity_name)
except (DataStoreSettingsImproperlyConfiguredException,
EngineNotImplementedException,
EngineConnectionException, FetchIndexForAliasException) as error_message:
raise APIHandlerException(str(error_message))
else:
raise APIHandlerException("{0} is not allowed.".format(request.method))

0 comments on commit 5979fd3

Please sign in to comment.