INNER CODE UNIT · Python
_create_gold_dict
dragondrop-cloud/cloud-concierge · nlpengine/main.py:137
def _create_gold_dict(current_cat: str, categories: List[str]) -> dict:
"""
Returns a "gold label" dictionary as required for training examples to be used
within a Spacy Text classification model.
For more details see: https://spacy.io/api/data-formats#dict-input
"""
gold_dict = {
"cats": {cat: 1.0 if cat == current_cat else 0.0 for cat in categories}
}
return gold_dict
def _join_text_components(example_text_list: List[str], end_index: int) -> str:
"""
Joins the text components within example_text_list into a single string.
"""
return ". ".join(example_text_list[:end_index]).replace(" ", " ") + "."