mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-24 05:18:58 +00:00
Reduce memory churn in RDRPOSTagger
This commit is contained in:
parent
618582dc74
commit
1f646e4f68
@ -36,4 +36,13 @@ public class FWObject
|
|||||||
context = new String[13];
|
context = new String[13];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reset(boolean check) {
|
||||||
|
if (check) {
|
||||||
|
System.arraycopy(contextPrototype, 0, context, 0, 13);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Arrays.fill(context, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,8 +103,10 @@ public class RDRPOSTagger
|
|||||||
var initialTags = InitialTagger.EnInitTagger4Sentence(FREQDICT, sentence);
|
var initialTags = InitialTagger.EnInitTagger4Sentence(FREQDICT, sentence);
|
||||||
|
|
||||||
String[] tags = new String[initialTags.length];
|
String[] tags = new String[initialTags.length];
|
||||||
|
FWObject object = new FWObject(true);
|
||||||
|
|
||||||
for (int i = 0; i < initialTags.length; i++) {
|
for (int i = 0; i < initialTags.length; i++) {
|
||||||
FWObject object = Utils.getObject(sentence, initialTags, initialTags.length, i);
|
Utils.getObject(object, sentence, initialTags, initialTags.length, i);
|
||||||
tags[i] = findFiredNode(object).conclusion;
|
tags[i] = findFiredNode(object).conclusion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,9 +123,9 @@ public class Utils
|
|||||||
return condition;
|
return condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FWObject getObject(String[] words, String[] tags, int size, int index)
|
public static FWObject getObject(FWObject object, String[] words, String[] tags, int size, int index)
|
||||||
{
|
{
|
||||||
FWObject object = new FWObject(true);
|
object.reset(true);
|
||||||
|
|
||||||
if (index > 1) {
|
if (index > 1) {
|
||||||
object.context[4] = words[index-2];
|
object.context[4] = words[index-2];
|
||||||
@ -175,9 +175,7 @@ public class Utils
|
|||||||
else
|
else
|
||||||
return "<T>";
|
return "<T>";
|
||||||
}
|
}
|
||||||
String conclusion = str.substring(str.indexOf("\"") + 1,
|
return str.substring(str.indexOf("\"") + 1, str.length() - 1);
|
||||||
str.length() - 1);
|
|
||||||
return conclusion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
|
Loading…
Reference in New Issue
Block a user