Skip to content

Commit 6f9a7b6

Browse files
author
Lukas Molzberger
committed
fixed overlapping acts
1 parent 16afe85 commit 6f9a7b6

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

src/main/java/org/aika/lattice/OrNode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ public void addActivation(Document doc, Integer ridOffset, NodeActivation inputA
142142
r = new Range(begin, end);
143143
}
144144

145+
if(r.begin == Integer.MIN_VALUE || r.end == Integer.MAX_VALUE) return;
146+
145147
Key nak = new Key(
146148
this,
147149
r,

src/test/java/org/aika/network/OverlappingOrTest.java

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
public class OverlappingOrTest {
4040

4141

42-
@Ignore
4342
@Test
4443
public void testOverlappingOr() {
4544
Model m = new Model();
@@ -60,30 +59,30 @@ public void testOverlappingOr() {
6059
// relative or absolute.
6160
Neuron pattern = m.initNeuron(
6261
m.createNeuron("BCD"),
63-
0.4,
62+
2.0,
6463
new Input()
6564
.setNeuron(inputNeurons.get('b'))
66-
.setWeight(1.0f)
65+
.setWeight(4.0f)
6766
.setRecurrent(false)
6867
.setRelativeRid(0)
69-
.setBiasDelta(0.5)
68+
.setBiasDelta(1.0)
7069
.setStartRangeMatch(Operator.EQUALS)
71-
.setEndRangeMatch(Operator.LESS_THAN_EQUAL)
70+
.setEndRangeMatch(Operator.GREATER_THAN_EQUAL)
7271
.setStartRangeOutput(true),
7372
new Input()
7473
.setNeuron(inputNeurons.get('c'))
7574
.setWeight(1.0f)
7675
.setRecurrent(false)
7776
.setRelativeRid(1)
78-
.setBiasDelta(0.5)
77+
.setBiasDelta(0.0)
7978
.setRangeMatch(RangeRelation.CONTAINS),
8079
new Input()
8180
.setNeuron(inputNeurons.get('d'))
82-
.setWeight(1.0f)
81+
.setWeight(4.0f)
8382
.setRecurrent(false)
8483
.setRelativeRid(2)
85-
.setBiasDelta(0.5)
86-
.setStartRangeMatch(Operator.GREATER_THAN_EQUAL)
84+
.setBiasDelta(1.0)
85+
.setStartRangeMatch(Operator.LESS_THAN_EQUAL)
8786
.setEndRangeMatch(Operator.EQUALS)
8887
.setEndRangeOutput(true)
8988
);
@@ -93,20 +92,11 @@ public void testOverlappingOr() {
9392
System.out.println(doc.neuronActivationsToString(true, false, true));
9493

9594
int wordPos = 0;
96-
for(int i = 0; i < doc.length(); i++) {
97-
char c = doc.getContent().charAt(i);
98-
if(c == ' ') {
99-
inputNeurons.get(c).addInput(doc, i, i + 1, wordPos++);
100-
}
101-
System.out.println(doc.neuronActivationsToString(true, false, true));
102-
}
103-
10495
for(int i = 0; i < doc.length(); i++) {
10596
char c = doc.getContent().charAt(i);
10697
if(c != ' ') {
107-
inputNeurons.get(c).addInput(doc, i, i + 1);
98+
inputNeurons.get(c).addInput(doc, i, i + 1, wordPos++);
10899
}
109-
110100
System.out.println(doc.neuronActivationsToString(true, false, true));
111101
}
112102

0 commit comments

Comments
 (0)