Skip to content

Commit 58b96b6

Browse files
committed
Improve typing
1 parent 18d3431 commit 58b96b6

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

chatterbot/tagging.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from typing import List, Union, Tuple
12
from chatterbot import languages
23
from chatterbot.utils import get_model_for_language
34
import spacy
@@ -20,15 +21,15 @@ def __init__(self, language=None):
2021
'chatterbot_lowercase_indexer', name='chatterbot_lowercase_indexer', last=True
2122
)
2223

23-
def get_text_index_string(self, text):
24+
def get_text_index_string(self, text: Union[str, List[str]]):
2425
if isinstance(text, list):
2526
documents = self.nlp.pipe(text)
2627
return [document._.search_index for document in documents]
2728
else:
2829
document = self.nlp(text)
2930
return document._.search_index
3031

31-
def as_nlp_pipeline(self, texts):
32+
def as_nlp_pipeline(self, texts: Union[List[str], Tuple[str, dict]]):
3233

3334
process_as_tuples = texts and isinstance(texts[0], tuple)
3435

@@ -52,7 +53,7 @@ def __init__(self, language=None):
5253
'chatterbot_bigram_indexer', name='chatterbot_bigram_indexer', last=True
5354
)
5455

55-
def get_text_index_string(self, text):
56+
def get_text_index_string(self, text: Union[str, List[str]]):
5657
"""
5758
Return a string of text containing part-of-speech, lemma pairs.
5859
"""
@@ -63,7 +64,7 @@ def get_text_index_string(self, text):
6364
document = self.nlp(text)
6465
return document._.search_index
6566

66-
def as_nlp_pipeline(self, texts):
67+
def as_nlp_pipeline(self, texts: Union[List[str], Tuple[str, dict]]):
6768
"""
6869
Accepts a single string or a list of strings, or a list of tuples
6970
where the first element is the text and the second element is a

0 commit comments

Comments
 (0)