Skip to content

Commit

Permalink
fix _does_all_examples_have_intents method at RepositoryVersionLanguage
Browse files Browse the repository at this point in the history
  • Loading branch information
helllllllder committed Jan 18, 2022
1 parent 7bd305a commit c8c4b00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bothub/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from django.utils.translation import ugettext_lazy as _
from django_elasticsearch_dsl_drf.wrappers import dict_to_obj
from elasticsearch_dsl import A
from elasticsearch_dsl import Q as elasticQ
from rest_framework import status
from rest_framework.exceptions import APIException

Expand Down Expand Up @@ -1108,7 +1109,13 @@ def _search_weak_intents_and_entities(self):
def _does_all_examples_have_intents(self):
from bothub.common.documents import RepositoryExampleDocument

search = RepositoryExampleDocument.search().query("match", intent_text="")
search = RepositoryExampleDocument.search().query(
"bool",
must=[
elasticQ("match", intent__text__raw=""),
elasticQ("match", repository_version_language__pk=self.pk),
],
)
return False if search.execute().hits.total.value != 0 else True

@property
Expand Down
1 change: 1 addition & 0 deletions bothub/common/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ def test_empty_intent(self):
RepositoryExampleEntity.objects.create(
repository_example=example, start=0, end=7, entity="name"
)

self.assertFalse(self.repository.current_version().ready_for_train)

def test_intent_dont_have_min_examples(self):
Expand Down

0 comments on commit c8c4b00

Please sign in to comment.