import language_tool_python

# 公開 API モード（Java 不要）
with language_tool_python.LanguageToolPublicAPI("en-US") as tool:
    text = "A sentence with a error in the Hitchhiker's Guide tot he Galaxy"
    matches = tool.check(text)

    print(f"検出: {len(matches)} 件の問題")
    for m in matches:
        print(f"  [{m.ruleId}] {m.message}")
        if m.replacements:
            print(f"  修正候補: {', '.join(m.replacements[:3])}")

    print("\n自動修正後:")
    print(tool.correct(text))

    # ルールを無効化してから再チェック
    tool.disabled_rules.update({"EN_A_VS_AN"})
    matches2 = tool.check(text)
    print(f"\nEN_A_VS_AN 無効化後: {len(matches2)} 件")