Exemplo 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]
Exemplo 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"]}
Exemplo n.º 3
0
 def text(self) -> typing.List[str]:
     return list(
         itertools.chain.from_iterable(
             [wordsegment.segment(name) for name in self.choices]
         )
     )
Exemplo n.º 4
0
 def get_type(self):
     t = (
         infer_type(" ".join(wordsegment.segment(self.name)))
         or cli_types.CliString()
     )
     return cli_types.CliList(t)
Exemplo n.º 5
0
 def text(self) -> typing.List[str]:
     return list(wordsegment.segment(self.name))
Exemplo n.º 6
0
 def get_type(self):
     return infer_type(" ".join(wordsegment.segment(self.name))) or None
Exemplo n.º 7
0
 def get_type(self):
     return cli_types.CliTuple(
         [infer_type(" ".join(wordsegment.segment(arg))) for arg in self.names]
     )