Skip to content

Commit 165ea50

Browse files
author
Lukas Molzberger
committed
InterprNode -> InterpretationNode
1 parent 5e385e2 commit 165ea50

22 files changed

+264
-292
lines changed

src/main/java/org/aika/Neuron.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
import org.aika.corpus.Document;
21-
import org.aika.corpus.InterprNode;
21+
import org.aika.corpus.InterpretationNode;
2222
import org.aika.lattice.InputNode;
2323
import org.aika.neuron.Activation;
2424
import org.aika.neuron.INeuron;
@@ -96,7 +96,7 @@ public Activation addInput(Document doc, int begin, int end, double value, Doubl
9696
* @param end The range end
9797
* @param o The interpretation node
9898
*/
99-
public Activation addInput(Document doc, int begin, int end, InterprNode o) {
99+
public Activation addInput(Document doc, int begin, int end, InterpretationNode o) {
100100
return addInput(doc, begin, end, null, o);
101101
}
102102

@@ -123,7 +123,7 @@ public Activation addInput(Document doc, int begin, int end, Integer rid) {
123123
* @param rid The relational id (e.g. the word position)
124124
* @param o The interpretation node
125125
*/
126-
public Activation addInput(Document doc, int begin, int end, Integer rid, InterprNode o) {
126+
public Activation addInput(Document doc, int begin, int end, Integer rid, InterpretationNode o) {
127127
return addInput(doc, begin, end, rid, o, 1.0);
128128
}
129129

@@ -138,7 +138,7 @@ public Activation addInput(Document doc, int begin, int end, Integer rid, Interp
138138
* @param o The interpretation node
139139
* @param value The activation value of this input activation
140140
*/
141-
public Activation addInput(Document doc, int begin, int end, Integer rid, InterprNode o, double value) {
141+
public Activation addInput(Document doc, int begin, int end, Integer rid, InterpretationNode o, double value) {
142142
return addInput(doc, begin, end, rid, o, value, null, 0);
143143
}
144144

@@ -153,7 +153,7 @@ public Activation addInput(Document doc, int begin, int end, Integer rid, Interp
153153
* @param value The activation value of this input activation
154154
* @param targetValue The target activation value for supervised learning
155155
*/
156-
public Activation addInput(Document doc, int begin, int end, Integer rid, InterprNode o, double value, Double targetValue, int fired) {
156+
public Activation addInput(Document doc, int begin, int end, Integer rid, InterpretationNode o, double value, Double targetValue, int fired) {
157157
return get(doc).addInput(doc, begin, end, rid, o, value, targetValue, fired);
158158
}
159159

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class Candidate implements Comparable<Candidate> {
1111
public Boolean cachedSNDecision;
1212
public SearchNode cachedSearchNode;
1313

14-
public InterprNode refinement;
14+
public InterpretationNode refinement;
1515

1616
int[] debugCounts = new int[3];
1717
int[] debugDecisionCounts = new int[3];
@@ -23,7 +23,7 @@ public class Candidate implements Comparable<Candidate> {
2323
int maxEnd;
2424
Integer minRid;
2525

26-
public Candidate(InterprNode ref, int id) {
26+
public Candidate(InterpretationNode ref, int id) {
2727
this.refinement = ref;
2828
this.id = id;
2929
ref.candidate = this;

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ public class Conflicts {
3535
public Map<Key, Conflict> secondary = new TreeMap<>();
3636

3737

38-
public static void collectConflicting(Collection<InterprNode> results, InterprNode n, long v) {
38+
public static void collectConflicting(Collection<InterpretationNode> results, InterpretationNode n, long v) {
3939
assert n.primId >= 0;
4040
n.conflicts.primary.values().forEach(c -> c.secondary.collectPrimitiveNodes(results, v));
4141
n.conflicts.secondary.values().forEach(c -> results.add(c.primary));
4242
}
4343

4444

45-
public static void add(NodeActivation act, InterprNode primary, InterprNode secondary) {
45+
public static void add(NodeActivation act, InterpretationNode primary, InterpretationNode secondary) {
4646
Key ck = new Key(secondary, act);
4747
Conflict c = primary.conflicts.primary.get(ck);
4848
if(c == null) {
49-
c = new Conflict(act, primary, secondary, InterprNode.add(primary.doc, false, primary, secondary));
49+
c = new Conflict(act, primary, secondary, InterpretationNode.add(primary.doc, false, primary, secondary));
5050

5151
c.conflict.isConflict++;
5252

@@ -63,12 +63,12 @@ public boolean hasConflicts() {
6363

6464
public static class Conflict {
6565
public NodeActivation act;
66-
public InterprNode primary;
67-
public InterprNode secondary;
68-
public InterprNode conflict;
66+
public InterpretationNode primary;
67+
public InterpretationNode secondary;
68+
public InterpretationNode conflict;
6969

7070

71-
public Conflict(NodeActivation act, InterprNode primary, InterprNode secondary, InterprNode conflict) {
71+
public Conflict(NodeActivation act, InterpretationNode primary, InterpretationNode secondary, InterpretationNode conflict) {
7272
this.act = act;
7373
this.primary = primary;
7474
this.secondary = secondary;
@@ -78,10 +78,10 @@ public Conflict(NodeActivation act, InterprNode primary, InterprNode secondary,
7878

7979

8080
public static class Key implements Comparable<Key> {
81-
public InterprNode o;
81+
public InterpretationNode o;
8282
public NodeActivation act;
8383

84-
public Key(InterprNode o, NodeActivation act) {
84+
public Key(InterpretationNode o, NodeActivation act) {
8585
this.o = o;
8686
this.act = act;
8787
}

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
import java.util.stream.Collectors;
3434
import java.util.stream.Stream;
3535

36-
import static org.aika.corpus.InterprNode.State.SELECTED;
37-
import static org.aika.corpus.InterprNode.State.UNKNOWN;
36+
import static org.aika.corpus.InterpretationNode.State.SELECTED;
37+
import static org.aika.corpus.InterpretationNode.State.UNKNOWN;
3838

3939
/**
4040
* The {@code Document} class represents a single document which may be either used for processing a text or as
@@ -62,7 +62,7 @@ public class Document implements Comparable<Document> {
6262
public int searchNodeIdCounter = 0;
6363
public int searchStepCounter = 0;
6464

65-
public InterprNode bottom = new InterprNode(this, -1, 0, 0);
65+
public InterpretationNode bottom = new InterpretationNode(this, -1, 0, 0);
6666

6767
public Model model;
6868
public int threadId;
@@ -88,9 +88,9 @@ public class Document implements Comparable<Document> {
8888

8989
public SearchNode rootSearchNode = new SearchNode(this, null, null, null, -1, Collections.emptySet(), false);
9090
public SearchNode selectedSearchNode = null;
91-
public List<InterprNode> rootRefs;
91+
public List<InterpretationNode> rootRefs;
9292
public ArrayList<Candidate> candidates;
93-
public List<InterprNode> bestInterpretation = null;
93+
public List<InterpretationNode> bestInterpretation = null;
9494

9595

9696
public static Comparator<NodeActivation> ACTIVATIONS_OUTPUT_COMPARATOR = (act1, act2) -> {
@@ -170,7 +170,7 @@ public void propagate() {
170170
private void expandRootRefinement() {
171171
rootRefs = new ArrayList<>();
172172
rootRefs.add(bottom);
173-
for (InterprNode pn : bottom.children) {
173+
for (InterpretationNode pn : bottom.children) {
174174
if (pn.state == SELECTED || (pn.isPrimitive() && pn.conflicts.primary.isEmpty() && pn.conflicts.secondary.isEmpty())) {
175175
rootRefs.add(pn);
176176
}
@@ -181,14 +181,14 @@ private void expandRootRefinement() {
181181
public void generateCandidates() {
182182
TreeSet<Candidate> tmp = new TreeSet<>();
183183
int i = 0;
184-
for (InterprNode cn : bottom.children) {
184+
for (InterpretationNode cn : bottom.children) {
185185
if (cn.state == UNKNOWN) {
186186
tmp.add(new Candidate(cn, i++));
187187
}
188188
}
189189

190190
long v = visitedCounter++;
191-
for (InterprNode n : rootRefs) {
191+
for (InterpretationNode n : rootRefs) {
192192
markCandidateSelected(n, v);
193193
}
194194

@@ -209,7 +209,7 @@ public void generateCandidates() {
209209
}
210210

211211

212-
private static void markCandidateSelected(InterprNode n, long v) {
212+
private static void markCandidateSelected(InterpretationNode n, long v) {
213213
if (n.neuronActivations != null) {
214214
for (Activation act : n.neuronActivations) {
215215
act.visited = v;
@@ -240,7 +240,7 @@ public void process() {
240240
SearchNode child = new SearchNode(this, rootSearchNode, null, c, 0, rootRefs, false);
241241
SearchNode.search(this, child);
242242

243-
ArrayList<InterprNode> results = new ArrayList<>();
243+
ArrayList<InterpretationNode> results = new ArrayList<>();
244244
results.add(bottom);
245245
if (selectedSearchNode != null) {
246246
selectedSearchNode.reconstructSelectedResult(this);
@@ -365,7 +365,7 @@ public String neuronActivationsToString(SearchNode sn, boolean withWeights, bool
365365
Set<Activation> acts = new TreeSet<>(ACTIVATIONS_OUTPUT_COMPARATOR);
366366

367367
for (INeuron n : activatedNeurons) {
368-
Stream<Activation> s = Activation.select(this, n, null, null, null, null, InterprNode.Relation.CONTAINED_IN);
368+
Stream<Activation> s = Activation.select(this, n, null, null, null, null, InterpretationNode.Relation.CONTAINED_IN);
369369
acts.addAll(s.collect(Collectors.toList()));
370370
}
371371

@@ -500,10 +500,10 @@ public void propagateWeight(int round, Activation act) {
500500
}
501501

502502

503-
public NormWeight adjustWeight(SearchNode cand, Collection<InterprNode> changed, long visitedModified) {
503+
public NormWeight adjustWeight(SearchNode cand, Collection<InterpretationNode> changed, long visitedModified) {
504504
long v = visitedCounter++;
505505

506-
for(InterprNode n: changed) {
506+
for(InterpretationNode n: changed) {
507507
addAllActs(n.getNeuronActivations());
508508
}
509509

@@ -524,7 +524,7 @@ private void addAllActs(Collection<Activation> acts) {
524524

525525

526526
public void add(int round, Activation act) {
527-
if(act.rounds.isQueued(round) || act.key.interpretation.state == InterprNode.State.UNKNOWN) return;
527+
if(act.rounds.isQueued(round) || act.key.interpretation.state == InterpretationNode.State.UNKNOWN) return;
528528

529529
TreeSet<Activation> q;
530530
if(round < queue.size()) {

0 commit comments

Comments
 (0)