Back to LanguageTool Homepage - Privacy - Imprint

How to ignore particular xml tag in LT

Dear LT Team,
how to ignore the grammar check or spell check in particular XML tag inside word

Examples:

Original String = this apple for <skip>yuo</skip>
Results =This apple for <skip>yuo</skip>

Tag inside “yuo” is misspelled but no need to check.
Is there any possibility. Please do the need full.
Thanks in advance.

If you use the HTTP API, you can use the data parameter as documented at https://languagetool.org/http-api/swagger-ui/#!/default/post_check. From Java, you’d need to define the text and markup ranges using AnnotatedTextBuilder.

1 Like

@rjnick,

An alternative is to add a rule in disambiguation.xml that ignores text that is inside a tag. Use this as a template:

<rule id="IGNORE_SPELLING_IN_XML_TAGS" name="Ignore spelling in XML tags">
    <pattern>
        <token regexp="yes">&lt;</token>
        <token regexp="yes">skip|mytag</token>
        <token regexp="yes">&gt;</token>
        <marker>
            <token regexp="yes">\p{L}+</token><!-- One or more letters in any language -->
        </marker>
        <token regexp="yes">&lt;</token>
        <token>/</token>
        <token><match no="1"/></token>
        <token regexp="yes">&gt;</token>
    </pattern>
    <disambig action="ignore_spelling"/>
</rule>

image

1 Like

@Mike_Unwalla thanks for your response. i will try and update to you

@rjnick,

I forgot…

To ignore the tags such that the grammar checking does not give an error for correct text (ignoring the tags), you can immunize the tags. (I have not done tests to confirm.) Refer to http://wiki.languagetool.org/developing-a-disambiguator#toc10.