Esempio n. 1
0
def segment_string(text: str):
    """
    Divides one larger word into segments
    :param text:
    :return:
    """

    base = text.lstrip("-")

    # Replace symbols with their unicode names
    translated = re.sub("[^[:alpha:]\s\-_]",
                        lambda match: human_readable_translate(match.group()),
                        base)

    dash_tokens = re.split("[-_ ]", translated)
    segment_tokens = itertools.chain.from_iterable(
        [wordsegment.segment(w) for w in dash_tokens])
    return [sanitize_token(tok) for tok in segment_tokens]
Esempio n. 2
0
 def reserved(self) -> Set[Tuple[str, ...]]:
     # Steal the keywords list from miniWDL
     return {tuple(wordsegment.segment(key)) for key in keywords["1.0"]}
Esempio n. 3
0
 def text(self) -> typing.List[str]:
     return list(
         itertools.chain.from_iterable(
             [wordsegment.segment(name) for name in self.choices]
         )
     )
Esempio n. 4
0
 def get_type(self):
     t = (
         infer_type(" ".join(wordsegment.segment(self.name)))
         or cli_types.CliString()
     )
     return cli_types.CliList(t)
Esempio n. 5
0
 def text(self) -> typing.List[str]:
     return list(wordsegment.segment(self.name))
Esempio n. 6
0
 def get_type(self):
     return infer_type(" ".join(wordsegment.segment(self.name))) or None
Esempio n. 7
0
 def get_type(self):
     return cli_types.CliTuple(
         [infer_type(" ".join(wordsegment.segment(arg))) for arg in self.names]
     )