Example #1
0
def main(senna_path="",
         sent="",
         dep_model="",
         batch=False,
         stp_dir="",
         init=False):

    annotator = Annotator(senna_path, stp_dir, dep_model)

    if not sent and batch:

        sent = [
            "He killed the man with a knife and murdered"
            "him with a dagger.",
            "He is a good boy.",
            "He created the robot and broke it after making it.",
        ]

    elif not sent:

        sent = "He created the robot and broke it after making it."

    if not batch:

        click.echo("\n", sent, "\n")

        sent = sent.split()
        args = "-srl -pos".strip().split()

        click.echo("conll:\n", annotator.get_conll_format(sent, args))

        temp = annotator.get_annoations(sent, dep_parse=True)

        click.echo("dep_parse:\n", temp["dep_parse"])

        click.echo("chunk:\n", temp["chunk"])

        click.echo("pos:\n", temp["pos"])

        click.echo("ner:\n", temp["ner"])

        click.echo("srl:\n", temp["srl"])

        click.echo("syntaxTree:\n", temp["syntax_tree"])

        click.echo("words:\n", temp["words"])

        click.echo("skip gram\n", list(skipgrams(sent, n=3, k=2)))

    else:

        click.echo("\n\nrunning batch process", "\n", "=" * 20, "\n", sent,
                   "\n")

        args = "-srl -pos".strip().split()

        click.echo("conll:\n", annotator.get_conll_format(sent, args))

        click.echo(Fore.BLUE + "CoNLL format is recommented for batch process")
Example #2
0
def main(senna_path='',
         sent='',
         dep_model='',
         batch=False,
         stp_dir='',
         init=False):

    annotator = Annotator(senna_path, stp_dir, dep_model)
    if not sent and batch:
        sent = [
            "He killed the man with a knife and murdered"
            "him with a dagger.", "He is a good boy.",
            "He created the robot and broke it after making it."
        ]
    elif not sent:
        sent = "He created the robot and broke it after making it."
    if not batch:
        print("\n", sent, "\n")
        sent = sent.split()
        args = '-srl -pos'.strip().split()
        print("conll:\n", annotator.get_conll_format(sent, args))
        temp = annotator.get_annoations(sent, dep_parse=True)['dep_parse']
        print('dep_parse:\n', temp)
        temp = annotator.get_annoations(sent, dep_parse=True)['chunk']
        print('chunk:\n', temp)
        temp = annotator.get_annoations(sent, dep_parse=True)['pos']
        print('pos:\n', temp)
        temp = annotator.get_annoations(sent, dep_parse=True)['ner']
        print('ner:\n', temp)
        temp = annotator.get_annoations(sent, dep_parse=True)['srl']
        print('srl:\n', temp)
        temp = annotator.get_annoations(sent, dep_parse=True)['syntax_tree']
        print('syntaxTree:\n', temp)
        temp = annotator.get_annoations(sent, dep_parse=True)['words']
        print('words:\n', temp)
        print('skip gram\n', list(skipgrams(sent, n=3, k=2)))

    else:
        print("\n\nrunning batch process", "\n", "=" * 20, "\n", sent, "\n")
        args = '-srl -pos'.strip().split()
        print("conll:\n", annotator.get_conll_format(sent, args))
        print(Fore.BLUE + "CoNLL format is recommented for batch process")