How to use pyLanguagetool - 10 common examples

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 / tests / test_converters.py View on Github external
def test_ipython_html2text():
    assert converters.html2text(ipython_html) == ipython_plaintext
github Findus23 / pyLanguagetool / tests / test_converters.py View on Github external
def test_html2text():
    assert converters.html2text(html) == plaintext
github Findus23 / pyLanguagetool / tests / test_api.py View on Github external
def test_languages_request():
    langs = api.get_languages(API_BASE_URL)
    assert isinstance(langs, list)
    assert len(langs) > 2
    found_german = False
    for i, dic in enumerate(langs):
        if dic["code"] == "de":
            found_german = True
    assert found_german
github Findus23 / pyLanguagetool / tests / test_converters.py View on Github external
def test_markdown2html():
    assert converters.markdown2html(markdown) == html
github Findus23 / pyLanguagetool / tests / test_converters.py View on Github external
def test_ipython_markdown2html():
    assert converters.markdown2html(ipython_markdown) == ipython_html
github Findus23 / pyLanguagetool / tests / test_converters.py View on Github external
def test_ipynb2markdown():
    assert converters.ipynb2markdown(ipython) == ipython_markdown
github Findus23 / pyLanguagetool / tests / test_cli.py View on Github external
✗ das ist ein est
    ^^^
  ✓ Das ist ein est

Möglicher Rechtschreibfehler gefunden
  ✗ das ist ein est
                ^^^
  ✓ das ist ein ist
  ✓ das ist ein es
  ✓ das ist ein erst
  ✓ das ist ein fest
  ✓ das ist ein West

Text checked by https://example.com/v2/ (LanguageTool 4.6)
"""
    pylanguagetool.print_errors(response, "https://example.com/v2/", False)
    out, err = capsys.readouterr()
    assert out == should_output
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)