本文整理汇总了Java中org.languagetool.rules.RuleMatch.getToPos方法的典型用法代码示例。如果您正苦于以下问题:Java RuleMatch.getToPos方法的具体用法?Java RuleMatch.getToPos怎么用?Java RuleMatch.getToPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.languagetool.rules.RuleMatch
的用法示例。
在下文中一共展示了RuleMatch.getToPos方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: acceptRuleMatch
import org.languagetool.rules.RuleMatch; //导入方法依赖的package包/类
@Nullable
@Override
public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> arguments, AnalyzedTokenReadings[] patternTokens) {
try {
String decade = arguments.get("lata").substring(2);
String century = arguments.get("lata").substring(0, 2);
int cent = Integer.parseInt(century);
String message = match.getMessage()
.replace("{dekada}", decade)
.replace("{wiek}", getRomanNumber(cent + 1));
return new RuleMatch(match.getRule(), match.getSentence(), match.getFromPos(), match.getToPos(), message, match.getShortMessage(),
match.getFromPos() == 0, null);
} catch (IllegalArgumentException ignore) {
// ignore it silently
return null;
}
}
示例2: getRuleMatches
import org.languagetool.rules.RuleMatch; //导入方法依赖的package包/类
@Override
protected List<RuleMatch> getRuleMatches(String word, int startPos, AnalyzedSentence sentence) throws IOException {
List<RuleMatch> ruleMatches = super.getRuleMatches(word, startPos, sentence);
if (ruleMatches.size() > 0) {
// so 'word' is misspelled:
IrregularForms forms = getIrregularFormsOrNull(word);
if (forms != null) {
RuleMatch oldMatch = ruleMatches.get(0);
RuleMatch newMatch = new RuleMatch(this, sentence, oldMatch.getFromPos(), oldMatch.getToPos(),
"Possible spelling mistake. Did you mean <suggestion>" + forms.forms.get(0) +
"</suggestion>, the " + forms.formName + " form of the " + forms.posName +
" '" + forms.baseform + "'?");
List<String> allSuggestions = new ArrayList<>();
allSuggestions.addAll(forms.forms);
for (String repl : oldMatch.getSuggestedReplacements()) {
if (!allSuggestions.contains(repl)) {
allSuggestions.add(repl);
}
}
newMatch.setSuggestedReplacements(allSuggestions);
ruleMatches.set(0, newMatch);
}
}
return ruleMatches;
}
示例3: TextMatch
import org.languagetool.rules.RuleMatch; //导入方法依赖的package包/类
public TextMatch(RuleMatch match) {
this.line = match.getLine();
this.column = match.getColumn();
this.endColumn = match.getEndColumn();
this.endLine = match.getEndLine();
this.fromPos = match.getFromPos();
this.toPos = match.getToPos();
this.message = match.getMessage();
this.ruleId = match.getRule().getId();
this.replacements = match.getSuggestedReplacements();
}
示例4: hasErrorCoveredByMatch
import org.languagetool.rules.RuleMatch; //导入方法依赖的package包/类
public boolean hasErrorCoveredByMatch(RuleMatch match) {
for (Error error : errors) {
if (match.getFromPos() <= error.getStartPos() && match.getToPos() >= error.getEndPos()) {
return true;
}
}
return false;
}
示例5: hasErrorOverlappingWithMatch
import org.languagetool.rules.RuleMatch; //导入方法依赖的package包/类
/** @since 3.2 */
public boolean hasErrorOverlappingWithMatch(RuleMatch match) {
for (Error error : errors) {
if (match.getFromPos() <= error.getStartPos() && match.getToPos() >= error.getEndPos() ||
match.getFromPos() >= error.getStartPos() && match.getFromPos() <= error.getEndPos() ||
match.getToPos() >= error.getStartPos() && match.getToPos() <= error.getEndPos()) {
return true;
}
}
return false;
}
示例6: errorAlreadyCounted
import org.languagetool.rules.RuleMatch; //导入方法依赖的package包/类
private boolean errorAlreadyCounted(RuleMatch match, List<Span> detectedErrorPositions) {
for (Span span : detectedErrorPositions) {
Span matchSpan = new Span(match.getFromPos(), match.getToPos());
if (span.covers(matchSpan) || matchSpan.covers(span)) {
return true;
}
}
return false;
}
示例7: WikipediaRuleMatch
import org.languagetool.rules.RuleMatch; //导入方法依赖的package包/类
WikipediaRuleMatch(Language language, RuleMatch match, String errorContext, AtomFeedItem feedItem) {
super(match.getRule(), match.getSentence(), match.getFromPos(), match.getToPos(), match.getMessage());
this.language = Objects.requireNonNull(language);
this.errorContext = Objects.requireNonNull(errorContext);
this.title = Objects.requireNonNull(feedItem.getTitle());
this.editDate = Objects.requireNonNull(feedItem.getDate());
this.diffId = feedItem.getDiffId();
}
示例8: isTouchedByOneOf
import org.languagetool.rules.RuleMatch; //导入方法依赖的package包/类
boolean isTouchedByOneOf(List<RuleMatch> matches) {
for (RuleMatch match : matches) {
if (offset <= match.getToPos() && offset + errorLength >= match.getFromPos()) {
return true;
}
}
return false;
}
示例9: createOOoError
import org.languagetool.rules.RuleMatch; //导入方法依赖的package包/类
/**
* Creates a SingleGrammarError object for use in LO/OO.
*/
private SingleProofreadingError createOOoError(RuleMatch ruleMatch, int startIndex, int sentencesLength, char lastChar) {
SingleProofreadingError aError = new SingleProofreadingError();
aError.nErrorType = TextMarkupType.PROOFREADING;
// the API currently has no support for formatting text in comments
aError.aFullComment = ruleMatch.getMessage()
.replaceAll("<suggestion>", "\"").replaceAll("</suggestion>", "\"")
.replaceAll("([\r]*\n)", " ");
// not all rules have short comments
if (!StringTools.isEmpty(ruleMatch.getShortMessage())) {
aError.aShortComment = ruleMatch.getShortMessage();
} else {
aError.aShortComment = aError.aFullComment;
}
aError.aShortComment = org.languagetool.gui.Tools.shortenComment(aError.aShortComment);
int numSuggestions = ruleMatch.getSuggestedReplacements().size();
String[] allSuggestions = ruleMatch.getSuggestedReplacements().toArray(new String[numSuggestions]);
// Filter: remove suggestions for override dot at the end of sentences
// needed because of error in dialog
if (lastChar == '.' && (ruleMatch.getToPos() + startIndex) == sentencesLength) {
int i;
for (i = 0; i < numSuggestions && i < MAX_SUGGESTIONS
&& allSuggestions[i].charAt(allSuggestions[i].length()-1) == '.'; i++);
if (i < numSuggestions && i < MAX_SUGGESTIONS) {
numSuggestions = 0;
allSuggestions = new String[0];
}
}
// End of Filter
if (numSuggestions > MAX_SUGGESTIONS) {
aError.aSuggestions = Arrays.copyOfRange(allSuggestions, 0, MAX_SUGGESTIONS);
} else {
aError.aSuggestions = allSuggestions;
}
aError.nErrorStart = ruleMatch.getFromPos() + startIndex;
aError.nErrorLength = ruleMatch.getToPos() - ruleMatch.getFromPos();
aError.aRuleIdentifier = ruleMatch.getRule().getId();
// LibreOffice since version 3.5 supports an URL that provides more
// information about the error,
// older version will simply ignore the property:
if (ruleMatch.getRule().getUrl() != null) {
aError.aProperties = new PropertyValue[] { new PropertyValue(
"FullCommentURL", -1, ruleMatch.getRule().getUrl().toString(),
PropertyState.DIRECT_VALUE) };
} else {
aError.aProperties = new PropertyValue[0];
}
return aError;
}
示例10: toString
import org.languagetool.rules.RuleMatch; //导入方法依赖的package包/类
private static String toString(RuleMatch match) {
return match.getRule().getId() + "/"+ match.getFromPos() + "-" + match.getToPos();
}