Skip to content

Commit 55c791f

Browse files
author
Lukas Molzberger
committed
removed follow flag from relations
1 parent 4d1a7c5 commit 55c791f

File tree

7 files changed

+33
-110
lines changed

7 files changed

+33
-110
lines changed

src/main/java/network/aika/lattice/AndNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public Refinement(RelationsMap relations, Provider<InputNode> input) {
356356

357357
public boolean isConvertible() {
358358
for(Relation rel: relations.relations) {
359-
if(rel != null && rel.isConvertible()) return true;
359+
if(rel != null) return true;
360360
}
361361
return false;
362362
}

src/main/java/network/aika/lattice/Converter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private List<Synapse> prepareCandidates() {
213213
for(Map.Entry<Integer, Relation> me: syn.getRelations().entrySet()) {
214214
Integer relId = me.getKey();
215215
Relation rel = me.getValue();
216-
if(rel.isConvertible() && !alreadyCollected.contains(relId)) {
216+
if(!alreadyCollected.contains(relId)) {
217217
Synapse rs = syn.getOutput().getSynapseById(relId);
218218
if(rs != null) {
219219
relatedSyns.put(relId, rs);

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

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,14 @@ public static class CommonAncestor extends AncestorRelation {
131131
public CommonAncestor() {
132132
}
133133

134-
public CommonAncestor(boolean follow) {
135-
this.follow = follow;
136-
}
137-
138134
@Override
139135
public int getType() {
140136
return TYPE;
141137
}
142138

143139
@Override
144140
public Relation invert() {
145-
return new CommonAncestor(follow);
141+
return new CommonAncestor();
146142
}
147143

148144
@Override
@@ -152,7 +148,6 @@ public boolean test(Activation act, Activation linkedAct, boolean allowUndefined
152148

153149
@Override
154150
public Stream<Activation> getActivations(INeuron n, Activation linkedAct) {
155-
if(!follow) return Stream.empty();
156151
List<Activation> results = new ArrayList<>();
157152
collectCommonAncestor(results, n, linkedAct, linkedAct.getNewVisitedId());
158153
return results.stream();
@@ -174,18 +169,14 @@ public static class IsDescendantOf extends AncestorRelation {
174169
public IsDescendantOf() {
175170
}
176171

177-
public IsDescendantOf(boolean follow) {
178-
this.follow = follow;
179-
}
180-
181172
@Override
182173
public int getType() {
183174
return TYPE;
184175
}
185176

186177
@Override
187178
public Relation invert() {
188-
return new IsAncestorOf(follow);
179+
return new IsAncestorOf();
189180
}
190181

191182
@Override
@@ -195,7 +186,6 @@ public boolean test(Activation act, Activation linkedAct, boolean allowUndefined
195186

196187
@Override
197188
public Stream<Activation> getActivations(INeuron n, Activation linkedAct) {
198-
if(!follow) return Stream.empty();
199189
List<Activation> results = new ArrayList<>();
200190
collectContains(results, n, linkedAct, linkedAct.getNewVisitedId());
201191
return results.stream();
@@ -217,18 +207,14 @@ public static class IsAncestorOf extends AncestorRelation {
217207
public IsAncestorOf() {
218208
}
219209

220-
public IsAncestorOf(boolean follow) {
221-
this.follow = follow;
222-
}
223-
224210
@Override
225211
public int getType() {
226212
return TYPE;
227213
}
228214

229215
@Override
230216
public Relation invert() {
231-
return new IsDescendantOf(follow);
217+
return new IsDescendantOf();
232218
}
233219

234220

@@ -239,7 +225,6 @@ public boolean test(Activation act, Activation linkedAct, boolean allowUndefined
239225

240226
@Override
241227
public Stream<Activation> getActivations(INeuron n, Activation linkedAct) {
242-
if(!follow) return Stream.empty();
243228
List<Activation> results = new ArrayList<>();
244229
collectContainedIn(results, n, linkedAct, linkedAct.getNewVisitedId());
245230
return results.stream();
@@ -261,18 +246,14 @@ public static class NotDescendantOf extends AncestorRelation {
261246
public NotDescendantOf() {
262247
}
263248

264-
public NotDescendantOf(boolean follow) {
265-
this.follow = follow;
266-
}
267-
268249
@Override
269250
public int getType() {
270251
return TYPE;
271252
}
272253

273254
@Override
274255
public Relation invert() {
275-
return new NotAncestorOf(follow);
256+
return new NotAncestorOf();
276257
}
277258

278259
@Override
@@ -282,7 +263,6 @@ public boolean test(Activation act, Activation linkedAct, boolean allowUndefined
282263

283264
@Override
284265
public Stream<Activation> getActivations(INeuron n, Activation linkedAct) {
285-
if(!follow) return Stream.empty();
286266
long v = linkedAct.getNewVisitedId();
287267
markDescendants(linkedAct, v);
288268

@@ -306,18 +286,14 @@ public static class NotAncestorOf extends AncestorRelation {
306286
public NotAncestorOf() {
307287
}
308288

309-
public NotAncestorOf(boolean follow) {
310-
this.follow = follow;
311-
}
312-
313289
@Override
314290
public int getType() {
315291
return TYPE;
316292
}
317293

318294
@Override
319295
public Relation invert() {
320-
return new NotDescendantOf(follow);
296+
return new NotDescendantOf();
321297
}
322298

323299
@Override
@@ -327,7 +303,6 @@ public boolean test(Activation act, Activation linkedAct, boolean allowUndefined
327303

328304
@Override
329305
public Stream<Activation> getActivations(INeuron n, Activation linkedAct) {
330-
if(!follow) return Stream.empty();
331306
long v = linkedAct.getNewVisitedId();
332307
markAncestors(linkedAct, v);
333308

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

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public MultiRelation() {
2929

3030

3131
public MultiRelation(boolean follow, SortedSet<Relation> relations) {
32-
super(follow);
3332
this.relations = relations;
3433
}
3534

@@ -92,7 +91,7 @@ public Relation invert() {
9291
for(Relation rel: relations) {
9392
invRels.add(rel.invert());
9493
}
95-
return new MultiRelation(follow, invRels);
94+
return new MultiRelation(invRels);
9695
}
9796

9897

@@ -117,14 +116,11 @@ public boolean isExact() {
117116

118117
@Override
119118
public Stream<Activation> getActivations(INeuron n, Activation linkedAct) {
120-
if(!follow) return Stream.empty();
121-
122119
if(relations.isEmpty()) {
123120
return n.getActivations(linkedAct.getDocument());
124121
} else {
125-
return relations
126-
.stream()
127-
.flatMap(r -> r.getActivations(n, linkedAct))
122+
return relations.first()
123+
.getActivations(n, linkedAct)
128124
.filter(act -> {
129125
for (Relation rel : relations) {
130126
if (!rel.test(act, linkedAct, false)) {
@@ -136,15 +132,6 @@ public Stream<Activation> getActivations(INeuron n, Activation linkedAct) {
136132
}
137133
}
138134

139-
@Override
140-
public boolean isConvertible() {
141-
for(Relation rel: relations) {
142-
if(rel.isConvertible()) return true;
143-
}
144-
145-
return false;
146-
}
147-
148135

149136
@Override
150137
public int compareTo(Relation rel) {

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

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ public PositionRelation(int fromSlot, int toSlot) {
2929
this.toSlot = toSlot;
3030
}
3131

32-
public PositionRelation(int fromSlot, int toSlot, boolean follow) {
33-
this.fromSlot = fromSlot;
34-
this.toSlot = toSlot;
35-
this.follow = follow;
36-
}
37-
3832

3933
@Override
4034
public boolean test(Activation act, Activation linkedAct, boolean allowUndefined) {
@@ -115,18 +109,14 @@ public Equals(int fromSlot, int toSlot) {
115109
super(fromSlot, toSlot);
116110
}
117111

118-
public Equals(int fromSlot, int toSlot, boolean follow) {
119-
super(fromSlot, toSlot, follow);
120-
}
121-
122112
@Override
123113
public int getType() {
124114
return TYPE;
125115
}
126116

127117
@Override
128118
public Relation invert() {
129-
return new Equals(toSlot, fromSlot, follow);
119+
return new Equals(toSlot, fromSlot);
130120
}
131121

132122
@Override
@@ -146,7 +136,6 @@ public boolean isExact() {
146136

147137
@Override
148138
public Stream<Activation> getActivations(INeuron n, Position pos) {
149-
if(!follow) return Stream.empty();
150139
return n.getActivations(pos.getDocument(),
151140
fromSlot, pos, true,
152141
fromSlot, pos, true
@@ -179,8 +168,8 @@ public LessThan(int fromSlot, int toSlot, boolean orEquals) {
179168
this.orEquals = orEquals;
180169
}
181170

182-
public LessThan(int fromSlot, int toSlot, boolean orEquals, boolean follow, int maxLength) {
183-
super(fromSlot, toSlot, follow);
171+
public LessThan(int fromSlot, int toSlot, boolean orEquals, int maxLength) {
172+
super(fromSlot, toSlot);
184173
this.orEquals = orEquals;
185174
this.maxLength = maxLength;
186175
}
@@ -192,7 +181,7 @@ public int getType() {
192181

193182
@Override
194183
public Relation invert() {
195-
return new GreaterThan(toSlot, fromSlot, orEquals, follow, maxLength);
184+
return new GreaterThan(toSlot, fromSlot, orEquals, maxLength);
196185
}
197186

198187

@@ -213,7 +202,6 @@ public boolean test(Position a, Position b) {
213202

214203
@Override
215204
public Stream<Activation> getActivations(INeuron n, Position pos) {
216-
if(!follow) return Stream.empty();
217205
return n.getActivations(
218206
pos.getDocument(),
219207
fromSlot, new Position(pos.getDocument(), maxLength != Integer.MAX_VALUE ? pos.getFinalPosition() - maxLength : Integer.MIN_VALUE), true,
@@ -264,8 +252,8 @@ public GreaterThan(int fromSlot, int toSlot, boolean orEquals) {
264252
this.orEquals = orEquals;
265253
}
266254

267-
public GreaterThan(int fromSlot, int toSlot, boolean orEquals, boolean follow, int maxLength) {
268-
super(fromSlot, toSlot, follow);
255+
public GreaterThan(int fromSlot, int toSlot, boolean orEquals, int maxLength) {
256+
super(fromSlot, toSlot);
269257
this.orEquals = orEquals;
270258
this.maxLength = maxLength;
271259
}
@@ -277,7 +265,7 @@ public int getType() {
277265

278266
@Override
279267
public Relation invert() {
280-
return new LessThan(toSlot, fromSlot, orEquals, follow, maxLength);
268+
return new LessThan(toSlot, fromSlot, orEquals, maxLength);
281269
}
282270

283271
@Override
@@ -296,7 +284,6 @@ public boolean test(Position a, Position b) {
296284

297285
@Override
298286
public Stream<Activation> getActivations(INeuron n, Position pos) {
299-
if(!follow) return Stream.empty();
300287
return n.getActivations(
301288
pos.getDocument(),
302289
fromSlot, pos, orEquals,

0 commit comments

Comments
 (0)