some prefomance turting

git-svn-id: https://russianmorphology.googlecode.com/svn/trunk@122 d817d54c-26ab-11de-abc9-2f7d1455ff7a
This commit is contained in:
Alexander.A.Kuznetsov
2010-10-18 12:24:50 +00:00
parent 43136e0de1
commit d46651f2ba
11 changed files with 19 additions and 206 deletions

View File

@ -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() {

View File

@ -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();
}
}