pyaiml21.utils.load_files.aiml_set_fromstring

pyaiml21.utils.load_files.aiml_set_fromstring(s: str) Set[str][source][source]

Guess the format and parse the AIML set.

The loaded set is normalized – in the sense that letters are uppercase-d and extra spaces removed.

Supported formats include:
  1. ALICE format: one line per phrase,

  2. Pandorabots format [json]: list of strings,

    or list of lists of words

Parameters

s – string with AIML set

Returns

parsed AIML set

Raises

ValueError if s does not represent an AIML set

Examples:
>>> s = "a\nb\nc"
>>> aiml_set_fromstring(s) == { "A", "B", "C" }
True
>>> s = '[["a"], ["b", "c"]]'
>>> aiml_set_fromstring(s) == { "A", "B C" }
True
>>> aiml_set_fromstring("") == set()
True
>>> aiml_set_fromstring("a") == {"A"}
True
>>> aiml_set_fromstring("a\n") == {"A"}
True