Skip to content

Commit 952321e

Browse files
author
Lukas Molzberger
committed
fixes
1 parent 894f22b commit 952321e

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

src/main/java/network/aika/neuron/INeuron.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,13 +406,13 @@ public Activation getActivation(Document doc, Range r, boolean onlyFinal) {
406406

407407
if (r.begin != null) {
408408
for (Activation act : th.getActivationsByRangeBegin(r.begin, true, r.begin, false)) {
409-
if (!onlyFinal || act.isFinalActivation()) {
409+
if ((!onlyFinal || act.isFinalActivation()) && r.equalsIgnoreNull(act.range)) {
410410
return act;
411411
}
412412
}
413413
} else if(r.end != null) {
414414
for (Activation act : th.getActivationsByRangeEnd(r.end, true, r.end, false)) {
415-
if (!onlyFinal || act.isFinalActivation()) {
415+
if (!onlyFinal || act.isFinalActivation() && r.equalsIgnoreNull(act.range)) {
416416
return act;
417417
}
418418
}

src/main/java/network/aika/neuron/range/Range.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ public boolean equals(Range r) {
100100
}
101101

102102

103+
public boolean equalsIgnoreNull(Range r) {
104+
if(begin != null && r.begin != null && !begin.compare(Operator.EQUALS, r.begin)) {
105+
return false;
106+
}
107+
if(end != null && r.end != null && !end.compare(Operator.EQUALS, r.end)) {
108+
return false;
109+
}
110+
111+
return true;
112+
}
113+
114+
103115
public String toString() {
104116
StringBuilder sb = new StringBuilder();
105117

@@ -142,7 +154,8 @@ public static class Relation implements Writable, Comparable<Relation> {
142154
public static Relation OVERLAPS = create(Operator.NONE, Operator.LESS_THAN, Operator.NONE, Operator.GREATER_THAN);
143155
public static Relation NONE = create(Operator.NONE, Operator.NONE);
144156
public static Relation BETWEEN = create(Operator.GREATER_THAN, Operator.LESS_THAN);
145-
157+
public static Relation BEFORE = create(Operator.NONE, Operator.NONE, Operator.NONE , Operator.LESS_THAN_EQUAL);
158+
public static Relation AFTER = create(Operator.NONE, Operator.NONE, Operator.NONE , Operator.GREATER_THAN_EQUAL);
146159

147160
public Operator beginToBegin = Operator.NONE;
148161
public Operator beginToEnd = Operator.NONE;

src/main/java/network/aika/neuron/relation/Relation.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ public static void addRelation(Map<Integer, Set<Relation>> relMap, Integer synId
6161
}
6262

6363

64+
public static Map<Integer, Set<Relation>> getRelationsMap(int synapseId, Neuron n) {
65+
if(synapseId == Synapse.OUTPUT) {
66+
INeuron in = n.get();
67+
if (in.outputRelations == null) {
68+
in.outputRelations = new TreeMap<>();
69+
}
70+
return in.outputRelations;
71+
} else {
72+
Synapse s = n.getSynapseById(synapseId);
73+
return s.relations;
74+
}
75+
}
76+
77+
6478
public static class Builder implements Neuron.Builder {
6579
private int from;
6680
private int to;
@@ -108,19 +122,6 @@ public void connect(Neuron n) {
108122
addRelation(toRel, from, r.invert());
109123
}
110124

111-
private static Map<Integer, Set<Relation>> getRelationsMap(int synapseId, Neuron n) {
112-
if(synapseId == Synapse.OUTPUT) {
113-
INeuron in = n.get();
114-
if (in.outputRelations == null) {
115-
in.outputRelations = new TreeMap<>();
116-
}
117-
return in.outputRelations;
118-
} else {
119-
Synapse s = n.getSynapseById(synapseId);
120-
return s.relations;
121-
}
122-
}
123-
124125
@Override
125126
public void registerSynapseIds(Neuron n) {
126127
n.registerSynapseId(from);

0 commit comments

Comments
 (0)