diff --git a/chatbot_ner/urls.py b/chatbot_ner/urls.py index 341208141..6acd460b0 100755 --- a/chatbot_ner/urls.py +++ b/chatbot_ner/urls.py @@ -49,5 +49,9 @@ url(r'^entities/train_crf_model', external_api.train_crf_model), url(r'^entities/languages/v1/(?P.+)$', external_api.entity_language_view), - url(r'^entities/data/v1/(?P.+)$', external_api.entity_data_view) + url(r'^entities/data/v1/(?P.+)$', external_api.entity_data_view), + + # Read unique values for text entity + url(r'^entities/values/v1/(?P.+)$', external_api.read_unique_values_for_text_entity), + ] diff --git a/external_api/api.py b/external_api/api.py index 3be5bafe1..b5dcc7b39 100644 --- a/external_api/api.py +++ b/external_api/api.py @@ -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))