How to use the pylanguagetool.api function in pyLanguagetool

To help you get started, we’ve selected a few pyLanguagetool examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Findus23 / pyLanguagetool / tests / test_api.py View on Github external
def test_request():
    response = api.check("This is an test", API_BASE_URL, "auto")
    assert "software" in response
    match = response["matches"][0]
    assert isinstance(match, dict)
github Findus23 / pyLanguagetool / pylanguagetool / __init__.py View on Github external
sys.exit(2)
    if config["input_type"]:
        inputtype = config["input_type"]
    if inputtype == "tex":
        print("pyLanguagetool doesn't support LaTeX out of the box.")
        print("But it doesn't have to:")
        print("You can simply use the output of detex")
        if config["input file"]:
            print("    $ detex {} | pylanguagetool".format(config["input file"]))
        print("or use the languagetool integration in TeXstudio.")
        sys.exit(3)
    check_text = converters.convert(input_text, inputtype)
    if config["single_line"]:
        found = False
        for line in check_text.splitlines():
            response = api.check(line, **config)
            print_errors(response,
                         config["api_url"],
                         not config["no_color"],
                         config["rules"],
                         config["rule_categories"]
                         )
            if len(response["matches"]) > 0:
                found = True
        if found:
            sys.exit(1)

    else:
        response = api.check(check_text, **config)
        print_errors(response,
                     config["api_url"],
                     not config["no_color"],
github Findus23 / pyLanguagetool / pylanguagetool / __init__.py View on Github external
found = False
        for line in check_text.splitlines():
            response = api.check(line, **config)
            print_errors(response,
                         config["api_url"],
                         not config["no_color"],
                         config["rules"],
                         config["rule_categories"]
                         )
            if len(response["matches"]) > 0:
                found = True
        if found:
            sys.exit(1)

    else:
        response = api.check(check_text, **config)
        print_errors(response,
                     config["api_url"],
                     not config["no_color"],
                     config["rules"],
                     config["rule_categories"],
                     config["explain_rule"]
                     )

        if len(response["matches"]) > 0:
            sys.exit(1)