Skip to content

Commit 168e432

Browse files
author
Lukas Molzberger
committed
minor refactoring
1 parent eacef39 commit 168e432

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/main/java/org/aika/corpus/Document.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public class Document implements Comparable<Document> {
8888
public ArrayList<Activation> addedActivations = new ArrayList<>();
8989

9090

91-
public SearchNode rootSearchNode = new SearchNode(this, null, null, null, -1, Collections.emptySet());
91+
public SearchNode rootSearchNode = new SearchNode(this, null, null, null, -1);
9292
public SearchNode selectedSearchNode = null;
9393
public ArrayList<Candidate> candidates;
9494
public List<InterpretationNode> bestInterpretation = null;
@@ -242,7 +242,7 @@ public void process() {
242242

243243
Candidate c = !candidates.isEmpty() ? candidates.get(0) : null;
244244

245-
SearchNode child = new SearchNode(this, rootSearchNode, null, c, 0, Collections.singleton(bottom));
245+
SearchNode child = new SearchNode(this, rootSearchNode, null, c, 0);
246246
SearchNode.searchIterative(this, child);
247247
// child.searchRecursive(this);
248248

@@ -517,11 +517,11 @@ public void add(int round, Activation act) {
517517
}
518518

519519

520-
public Weight process(SearchNode sn, Collection<InterpretationNode> changed) {
520+
public Weight process(SearchNode sn) {
521521
long v = visitedCounter++;
522522

523-
for(InterpretationNode n: changed) {
524-
addAll(n.getActivations());
523+
if(sn.getParent() != null && sn.getParent().candidate != null) {
524+
addAll(sn.getParent().candidate.refinement.getActivations());
525525
}
526526

527527
Weight delta = Weight.ZERO;

src/main/java/org/aika/corpus/SearchNode.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ enum Step {
100100
}
101101

102102

103-
public SearchNode(Document doc, SearchNode selParent, SearchNode exclParent, Candidate c, int level, Collection<InterpretationNode> changed) {
103+
public SearchNode(Document doc, SearchNode selParent, SearchNode exclParent, Candidate c, int level) {
104104
id = doc.searchNodeIdCounter++;
105105
this.level = level;
106106
visited = doc.visitedCounter++;
@@ -134,7 +134,7 @@ public SearchNode(Document doc, SearchNode selParent, SearchNode exclParent, Can
134134
}
135135

136136
if(modified) {
137-
weightDelta = doc.vQueue.process(this, changed);
137+
weightDelta = doc.vQueue.process(this);
138138
markDirty();
139139

140140
if(candidate != null) {
@@ -151,7 +151,7 @@ public SearchNode(Document doc, SearchNode selParent, SearchNode exclParent, Can
151151
act.saveNewState();
152152
}
153153
} else {
154-
weightDelta = doc.vQueue.process(this, changed);
154+
weightDelta = doc.vQueue.process(this);
155155
if (Math.abs(weightDelta.w - csn.weightDelta.w) > 0.00001 || !compareNewState(csn)) {
156156
log.error("Cached search node activation do not match the newly computed results.");
157157
log.info("Computed results:");
@@ -427,7 +427,7 @@ private boolean prepareSelectStep(Document doc) {
427427
}
428428

429429
Candidate c = doc.candidates.size() > level + 1 ? doc.candidates.get(level + 1) : null;
430-
selectedChild = new SearchNode(doc, this, excludedParent, c, level + 1, Collections.singleton(candidate.refinement));
430+
selectedChild = new SearchNode(doc, this, excludedParent, c, level + 1);
431431

432432
candidate.debugDecisionCounts[0]++;
433433

@@ -441,7 +441,7 @@ private boolean prepareExcludeStep(Document doc) {
441441
candidate.refinement.setState(EXCLUDED, visited);
442442

443443
Candidate c = doc.candidates.size() > level + 1 ? doc.candidates.get(level + 1) : null;
444-
excludedChild = new SearchNode(doc, selectedParent, this, c, level + 1, Collections.singleton(candidate.refinement));
444+
excludedChild = new SearchNode(doc, selectedParent, this, c, level + 1);
445445

446446
candidate.debugDecisionCounts[1]++;
447447

0 commit comments

Comments
 (0)