Comments (1)
Some ideas to approach this issue:
- Start at
PatternRuleMatcher.formatMatches
- If you replace the body of the
if(!newWay)
-block by
int skipped = 0;
String replacement = tokenReadings[firstMatchTok + repTokenPos - 1].getToken();
if (j >= patternTokenMatchers.size()) {
//System.err.println("Rule "+rule.getFullId()+" refers to token \\"+(j+1)+" but has only "+patternTokenMatchers.size()+" tokens.");
} else if(patternTokenMatchers.get(j).getPatternToken().getMaxOccurrence() > 1 &&
(j == 0 || patternTokenMatchers.get(j-1).getPatternToken().getSkipNext() < 1)) {
// for matched tokens with max="x" where x > 1, the entire token is returned
for (int idx = positions.get(j) - 1; idx > 0; idx--) {
skipped++;
replacement = tokenReadings[firstMatchTok + repTokenPos - 1 - skipped].getToken().concat(" ").concat(replacement);
}
}
// in case <match> elements weren't used (yet)
errorMessage = errorMessage.replace("\\" + (j + 1),
replacement);
The following rule will work correctly:
<rule id="test_referencing_token_with_max" name="Test referencing a token by \y with max='x', where x > 1">
<pattern>
<token max="2">abc</token>
<token max="2">def</token>
</pattern>
<message>A repeated token should be repeated in the suggestion: <suggestion>\1first \2second</suggestion></message>
<example correction="abc abcfirst defsecond">That's <marker>abc abc def</marker>.</example>
<example correction="abc abcfirst def defsecond">That's <marker>abc abc def def</marker>.</example>
<example correction="abcfirst defsecond">That's <marker>abc def</marker>.</example>
</rule>
However, this will not change the behavior of rule where the referencing is done by <match no="1"/>
(= newWay = true)
from languagetool.
Related Issues (20)
- [de] Bullet points that aren't a sentence must/should not be written in caps
- Additional suggestion for IVE_I_HAVE_AMERICAN_STYLE rule
- error within vaadin text fields (text input fields vanish on click) HOT 3
- Request for Self-Hosted AI LLM Download Option
- case_sensitive='yes' doesn't work properly in antipattern — 2024-05-29
- ru: false positive with беспроводной
- New German suggestion(s) HOT 4
- [MacOS] Add an option to remove the app icon from the menu bar HOT 2
- [de] `Pepsinwein` erroneously marked as error
- Valencian language
- Languagetool extension 6.4 gives out an error message while saveing the file. HOT 1
- [en] LT from the command line: don't give useless message [enhancement request] HOT 1
- Phrases aren't matched by rules unless they are the provided example sentences HOT 1
- Languagetool vs WYSIWYG HOT 1
- Shadow DOM breaks CSS inherit HOT 1
- [pt] Idea for rule: “naquele” → “no” — 2024-06-25 HOT 3
- Sentence splitting issues HOT 3
- Pequeno erro no dicionário de português
- LanguageTool injects code / modifies dom even if it's disabled
- Overlay beneath focused window HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from languagetool.