@textlint-ja/textlint-rule-preset-ai-writing

repository·main·Indexed 22 days ago

https://github.com/textlint-ja/textlint-rule-preset-ai-writing

A textlint rule preset designed to detect and correct common writing patterns found in AI-generated Japanese text to promote more natural and professional expressions. It includes rules to identify mechanical list formatting, hyperbolic 'hype' expressions, specific emphasis patterns, and English-style colon continuations. Additionally, it provides an ai-tech-writing-guideline rule based on the '7 Cs' of effective technical writing to improve conciseness, clarity, and concreteness.

Tokens
3.8K
Snippets
11
Records
17
Agent score
76%

What's inside @textlint-ja/textlint-rule-preset-ai-writing

  1. Understand the Technical Writing Guidelines used by ai-tech-writing-guideline

    main

    The ai-tech-writing-guideline rule is based on the '7 Cs' of effective technical writing. These principles aim to create natural, readable, and professional technical documentation.

    The 7 Cs of Technical Writing

    • Clear (明確): No ambiguity; easy to understand.
    • Concise (簡潔): Express necessary information with minimal words.
    • Correct (正確): No errors in grammar, facts, or technical content.
    • Coherent (一貫): Logically connected and flows smoothly.
    • Concrete (具体的): Not abstract; measurable and clear.
    • Complete (完全): Includes all necessary information.
    • Courteous (丁寧): Appropriate tone and structure for the reader.

    Core Principles for Implementation

    1. Conciseness (簡潔性): Eliminate redundant expressions (e.g., replacing "まず最初に" with "まず").
    2. Clarity (明確性): Use active voice and specific verbs instead of passive voice (e.g., replacing "処理が行われます" with "システムが処理します").
    3. Concreteness (具体性): Replace abstract terms with measurable, quantitative data (e.g., replacing "高速なパフォーマンス" with "50ms未満の応答時間").
    4. Consistency (一貫性): Unify terminology (e.g., choosing between "ユーザー" and "クライアント") and sentence endings (e.g., sticking to either "です・ます" or "だ・である").
    5. Structure (構造化): Follow "one sentence, one idea" (一文一義), keep sentences under 50 characters where possible, and use lists/headings for logical organization.
  2. Use regular expressions in the 'allows' option

    main

    The allows option in any of the preset's rules accepts an array of strings. You can provide exact string matches or regular expression patterns using the regexp-string-matcher format.

    Supported regex formats:

    • /pattern/ : Basic regular expression.
    • /pattern/i : Case-insensitive match.
    • /pattern/m : Multiline match.

    Note: When using special characters in a regex string (like *), ensure they are properly escaped.

    {
        "allows": [
            "特定の文字列", // Exact match
            "/パターン/", // Basic regex
            "/パターン/i", // Case-insensitive
            "/パターン/m", // Multiline
            "/重要.*/", // Starts with '重要'
            "/\\*\\*注意\\*\\*/", // **注意** (escaped special characters)
            "/TODO.*/i", // Starts with TODO (case-insensitive)
            "/\\d{4}-\\d{2}-\\d{2}/" // Date format (YYYY-MM-DD)
        ]
    }
  3. Run textlint as an MCP server

    main

    This preset is optimized for workflows where an AI checks and improves its own generated text. By running textlint as an MCP (Model Context Protocol) server, you can integrate it with AI tools like Claude Code or VSCode Copilot to create a feedback loop:

    1. The AI tool generates text.
    2. The text is checked via the textlint MCP server.
    3. The AI tool uses the results to propose improvements or corrections.

    Note: This requires textlint v14.8.0 or later. For detailed configuration, refer to the textlint MCP documentation.

    npx textlint --mcp
  4. Replace abstract terms with Concrete data

    main

    Avoid vague, abstract descriptions. Instead, use measurable or quantitative information to provide concrete details.

    Abstract ExpressionConcrete ExampleEffect
    高速なパフォーマンス (High performance)50ms未満の応答時間 (Response time < 50ms)Measurable criteria
    大幅に向上 (Significant improvement)従来比200%向上 (200% improvement vs previous)Quantitative info
    効率的な (Efficient)メモリ使用量を30%削減 (Reduce memory by 30%)Specific effect
    適切な (Appropriate)セキュリティ基準に準拠した (Compliant with security standards)Clear judgment criteria

    Examples

    ❌ このAPIは高速なパフォーマンスを提供します。
    ✅ このAPIは50ms未満で応答します。
    
    ❌ 大幅にパフォーマンスが向上しました。
    ✅ 処理速度が従来比200%向上しました。
  5. Use active voice for Clarity

    main

    To improve clarity, convert passive expressions into active ones. This makes the subject and the actor of the action clear.

    Passive ExpressionActive ExpressionEffect
    処理が行われます (Processing is performed)システムが処理します (The system processes)Subject is clear
    データの変更を行う (Perform data change)データを変更する (Change data)Direct action
    によって実行される (Is executed by)○○が実行する (XX executes)Actor is clear

    Examples

    ❌ データの検証が行われます。
    ✅ システムがデータを検証します。
    
    ❌ ファイルの変更を行ってください。
    ✅ ファイルを変更してください。
  6. Eliminate redundant expressions for Conciseness

    main

    To improve conciseness, avoid redundant or unnecessary auxiliary verbs and introductory phrases. Use the following mapping as a guide for improvement:

    Detected ExpressionRecommended ExpressionReason
    まず最初に (First of all)まず / 最初に (First)Redundancy
    あらかじめ予測 (Predict in advance)予測 (Predict)"Predict" implies prior knowledge
    することができます (Can do)できます / します (Can / Do)Unnecessary auxiliary verb duplication
    する必要があります (Need to do)してください / します (Please / Do)More direct expression
    言うまでもなく (It goes without saying)(Delete)Unnecessary filler

    Examples

    ❌ まず最初に設定ファイルを開く必要があります。
    ✅ まず、設定ファイルを開きます。
    
    ❌ このAPIを使用することができます。
    ✅ このAPIを使用できます。
  7. Configure no-ai-hype-expressions rule

    main

    Detects hyperbolic or "hype" expressions common in AI writing (e.g., "revolutionary technology", "game changer", "unleash possibilities").

    Options

    • allows: A string or regex (e.g., "/革命的な.*/") to allow specific patterns without reporting errors.
    • disableAbsolutenessPatterns: Set to true to disable detection of expressions implying absolute or complete solutions.
    • disableAbstractPatterns: Set to true to disable detection of abstract or purely sensory/emotional expressions.
    • disabledPredictivePatterns: Set to true to disable detection of authoritative or prophetic expressions.
  8. Configure @textlint-ja/preset-ai-writing options

    main

    You can configure options for each rule within the @textlint-ja/preset-ai-writing preset in your .textlintrc (or equivalent configuration file). Each rule has specific options to allow certain patterns or disable specific guidance categories.

    Available rules that can be configured:

    • no-ai-list-formatting
    • no-ai-hype-expressions
    • no-ai-emphasis-patterns
    • no-ai-colon-continuation
    • ai-tech-writing-guideline
    {
        "rules": {
            "@textlint-ja/preset-ai-writing": {
                "no-ai-list-formatting": {
                    "allows": ["許可したいテキスト", "/正規表現パターン/i"],
                    "disableBoldListItems": false,
                    "disableEmojiListItems": false
                },
                "no-ai-hype-expressions": {
                    "allows": ["許可したいテキスト", "/正規表現パターン/"],
                    "disableAbsolutenessPatterns": false,
                    "disableAbstractPatterns": false,
                    "disabledPredictivePatterns": false
                },
                "no-ai-emphasis-patterns": {
                    "allows": ["許可したいテキスト", "/正規表現パターン/"],
                    "disableEmojiEmphasisPatterns": false,
                    "disableInfoPatterns": false,
                    "disableHeadingEmphasisPatterns": false
                },
                "no-ai-colon-continuation": {
                    "allows": ["許可したいテキスト", "/正規表現パターン/"],
                    "disableCodeBlock": false,
                    "disableList": false,
                    "disableQuote": false,
                    "disableTable": false
                },
                "ai-tech-writing-guideline": {
                    "severity": "info",
                    "allows": ["許可したいテキスト", "/正規表現パターン/"],
                    "disableRedundancyGuidance": false,
                    "disableVoiceGuidance": false,
                    "disableClarityGuidance": false,
                    "disableConsistencyGuidance": false,
                    "disableStructureGuidance": false,
                    "enableDocumentAnalysis": true
                }
            }
        }
    }
  9. Configure no-ai-list-formatting rule

    main

    Detects list item patterns that may feel mechanical (e.g., using bold prefixes like **Important**: or emojis like ).

    Options

    • allows: A string or regex (e.g., "/重要.*/i") to allow specific patterns without reporting errors.
    • disableBoldListItems: Set to true to disable detection of bolded list items.
    • disableEmojiListItems: Set to true to disable detection of emoji list items.
  10. Configure ai-tech-writing-guideline rule

    main

    Provides suggestions for improving document quality based on technical writing best practices, covering conciseness, clarity, specificity, consistency, and structure.

    Options

    • allows: A string or regex to allow specific patterns without reporting errors.
    • severity: Set to "info" to treat findings as suggestions rather than errors.
    • disableRedundancyGuidance: Set to true to disable redundancy detection.
    • disableVoiceGuidance: Set to true to disable active/passive voice detection.
    • disableClarityGuidance: Set to true to disable clarity detection.
    • disableConsistencyGuidance: Set to true to disable consistency detection.
    • disableStructureGuidance: Set to true to disable structure/organization detection.
    • enableDocumentAnalysis: Set to true to enable analysis of the entire document.

    It is recommended to use this alongside textlint-rule-preset-ja-technical-writing to fix definite errors while receiving additional improvement suggestions via severity: "info".

    {
        "rules": {
            "preset-ja-technical-writing": true,
            "@textlint-ja/preset-ai-writing": {
                "ai-tech-writing-guideline": {
                    "severity": "info"
                }
            }
        }
    }
  11. Configure no-ai-emphasis-patterns rule

    main

    Detects mechanical emphasis patterns often used by AI (e.g., bolding entire headings or specific words within sentences).

    Options

    • allows: A string or regex to allow specific patterns without reporting errors.
    • disableEmojiEmphasisPatterns: Set to true to disable detection of combinations of emojis and bold text.
    • disableInfoPatterns: Set to true to disable detection of information-style prefix patterns.
    • disableHeadingEmphasisPatterns: Set to true to disable detection of bold patterns within headings.