Back to LanguageTool Homepage - Privacy - Imprint

MANY_NN replacement contains a trailing whitespace


(Erik van Leeuwen) #1

Hello,

I’ve executed an en-US grammar check for the following text (using the API):
“There are a few JavaScript XPath implementations.”

The response contains a match for the MANY_NN rule telling me to replace “few JavaScript” with "few " (notice the trailing whitespace). If I execute that replacement the sentence would contain a double whitespace between the words few and XPath.

The match response:

{
	"message": "Possible agreement error. The noun JavaScript seems to be countable; consider using: \"few \".",
	"shortMessage": "Grammatical problem",
	"replacements": [
		{
			"value": "few "
		}
	],
	"offset": 12,
	"length": 14,
	"context": {
		"text": "There are a few JavaScript XPath implementations.",
		"offset": 12,
		"length": 14
	},
	"sentence": "There are a few JavaScript XPath implementations.",
	"rule": {
		"id": "MANY_NN",
		"subId": "1",
		"description": "Possible agreement error: 'many/several/few' + singular countable noun",
		"issueType": "grammar",
		"category": {
			"id": "GRAMMAR",
			"name": "Grammar"
		}
	}
}

The MANY_NN rule message is:

<message>Possible agreement error. The noun <match no="2"/> seems to be countable; consider using: <suggestion><match no="1"/> <match suppress_misspelled="yes" no="2" postag="NNP?S" postag_regexp="yes"/></suggestion>.</message>

I think the whitespace in the <suggestion> between the <match no="1"/> and <match no="2"/> is causing this. Is this intended behavior? Is or should there be an option to only add the trailing whitespace when the <match no="2"/> is present?


(Daniel Naber) #2

The basic issue seems to be that a rule matches here that doesn’t consider the whole chunk of “JavaScript XPath implementations”. You can use https://community.languagetool.org/analysis/index?lang=en to see how text is analyzed, and in this case, the chunk is detected correctly (I-NP-plural, I-NP-plural, E-NP-plural). So I think a better approach would be to fix the matching first before looking at the suggestions. You can look for chunk="..." in grammar.xml to see how chunks can be addressed in XML rules.