Check text consistency

One use case for Schematron using AI is to check if the text in an XML document is consistent and easy to read and understand. For example, you may want to ensure that the text is written in plain language, uses simple sentence structures, and avoids technical jargon or complex terminology. To achieve this, you can define a Schematron rule that checks for specific patterns or structures in the text. For instance, you may define a rule that checks if the sentences are too long or if the text contains too many complex words or phrases. If the rule detects any issues, it can report an error or a warning to the user, indicating the specific location of the problem.

Example 4. Example a Schematron rule that verifies if the text is easy to read and understand

<sch:rule context="p">
    <sch:assert test="ai:verify-content('Is the text easy to read and understand?', .)">
        The text in not easy to read and understand</sch:assert>
</sch:rule>


Once you have identified the issues in the text, you can use SQF (Schematron Quick Fixes) to provide suggestions or corrections to the user. For example, you may provide a suggestion to correct the text to be easy to read and understand by calling the ai:transform-content() function.

Example 5. SQF fix that corrects the text to be easy to read and understand

<sqf:fix id="rephrase">
    <sqf:description>
        <sqf:title>Correct the consistency of the text</sqf:title>
    </sqf:description>
    <sqf:replace match="text()" select="ai:transform-content(
		'Correct the text to be easy to read and understand', .)"/>
</sqf:fix>