Skip to content

utils

allennlp.confidence_checks.task_checklists.utils

[SOURCE]


add_common_lexicons

def add_common_lexicons(editor: Editor)

Add commonly used lexicons to the editor object. These can be used in all the task suites.

Note: Updates the editor object in place.

spacy_wrap

def spacy_wrap(
    fn: Callable,
    language: str = "en_core_web_sm",
    **kwargs
) -> Callable

Wrap the function so that it runs the input text data through a spacy model before the function call.

strip_punctuation

def strip_punctuation(data: Union[str, spacy.tokens.doc.Doc]) -> str

Removes all punctuation from data.

toggle_punctuation

def toggle_punctuation(data: str) -> List[str]

If data contains any punctuation, it is removed. Otherwise, a . is added to the string. Returns a list of strings.

Eg. data = "This was great!" Returns ["This was great", "This was great."]

data = "The movie was good" Returns ["The movie was good."]

random_string

def random_string(n: int) -> str

Returns a random alphanumeric string of length n.

random_url

def random_url(n: int = 6) -> str

Returns a random url of length n.

random_handle

def random_handle(n: int = 6) -> str

Returns a random handle of length n. Eg. "@randomstr23`

add_random_strings

def add_random_strings(data: str) -> List[str]

Adds random strings to the start and end of the string data. Returns a list of strings.