some prefomance turting
git-svn-id: https://russianmorphology.googlecode.com/svn/trunk@122 d817d54c-26ab-11de-abc9-2f7d1455ff7a
This commit is contained in:
@ -39,9 +39,9 @@ public class Heuristic implements Serializable {
|
||||
this.normalFormMorphInfo = normalFormMorphInfo;
|
||||
}
|
||||
|
||||
public String transformWord(String w) {
|
||||
if (w.length() - actualSuffixLength < 0) return w;
|
||||
return w.substring(0, w.length() - actualSuffixLength) + actualNormalSuffix;
|
||||
public StringBuilder transformWord(String w) {
|
||||
if (w.length() - actualSuffixLength < 0) return new StringBuilder(w);
|
||||
return new StringBuilder(w.substring(0, w.length() - actualSuffixLength)).append(actualNormalSuffix);
|
||||
}
|
||||
|
||||
public byte getActualSuffixLength() {
|
||||
|
@ -51,7 +51,7 @@ public class MorphologyImpl implements Morphology {
|
||||
int[] ints = decoderEncoder.encodeToArray(revertWord(s));
|
||||
int ruleId = findRuleId(ints);
|
||||
for (Heuristic h : rules[rulesId[ruleId]]) {
|
||||
result.add(h.transformWord(s));
|
||||
result.add(h.transformWord(s).toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -61,7 +61,7 @@ public class MorphologyImpl implements Morphology {
|
||||
int[] ints = decoderEncoder.encodeToArray(revertWord(s));
|
||||
int ruleId = findRuleId(ints);
|
||||
for (Heuristic h : rules[rulesId[ruleId]]) {
|
||||
result.add(h.transformWord(s) + "|" + grammarInfo[h.getFormMorphInfo()]);
|
||||
result.add(h.transformWord(s).append("|").append(grammarInfo[h.getFormMorphInfo()]).toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -192,10 +192,10 @@ public class MorphologyImpl implements Morphology {
|
||||
}
|
||||
|
||||
protected String revertWord(String s) {
|
||||
String result = "";
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 1; i <= s.length(); i++) {
|
||||
result += s.charAt(s.length() - i);
|
||||
result.append(s.charAt(s.length() - i));
|
||||
}
|
||||
return result;
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user