coli-saar / alto

Alto, the Algebraic Language Toolkit
Other
17 stars 2 forks source link

ArrayIndexOutOfBoundsException in SGraph#equals #61

Open alexanderkoller opened 4 years ago

alexanderkoller commented 4 years ago

Equals comparison of certain s-graphs generates the following exception. @jgroschwitz Is this code that you understand? Could this be fixed by upgrading to a more recent version of jgrapht?

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2
    at org.jgrapht.experimental.isomorphism.EquivalenceIsomorphismInspector.reorderTargetArrayToMatchSourceOrder(Unknown Source)
    at org.jgrapht.experimental.isomorphism.EquivalenceIsomorphismInspector.createPermutationIterator(Unknown Source)
    at org.jgrapht.experimental.isomorphism.AbstractExhaustiveIsomorphismInspector.init(Unknown Source)
    at org.jgrapht.experimental.isomorphism.AbstractExhaustiveIsomorphismInspector.<init>(Unknown Source)
    at org.jgrapht.experimental.isomorphism.EquivalenceIsomorphismInspector.<init>(Unknown Source)
    at org.jgrapht.experimental.isomorphism.AdaptiveIsomorphismInspectorFactory.createTopologicalExhaustiveInspector(Unknown Source)
    at org.jgrapht.experimental.isomorphism.AdaptiveIsomorphismInspectorFactory.createAppropriateConcreteInspector(Unknown Source)
    at org.jgrapht.experimental.isomorphism.AdaptiveIsomorphismInspectorFactory.createIsomorphismInspector(Unknown Source)
    at de.up.ling.irtg.algebra.graph.SGraph.isIsomorphicAlsoEdges(SGraph.java:1123)
    at de.up.ling.irtg.algebra.graph.SGraph.equals(SGraph.java:764)
    at java.base/java.util.Objects.equals(Objects.java:77)
    at de.saar.coli.irtg.experimental.astar.SupertagWithType.equals(SupertagWithType.java:42)
    at it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap.containsKey(Object2IntOpenHashMap.java:424)
    at de.up.ling.irtg.signature.Interner.isKnownObject(Interner.java:197)
    at de.saar.coli.irtg.experimental.astar.io.TextScoreReader.processSupertagProbabilities(TextScoreReader.java:118)
    at de.saar.coli.irtg.experimental.astar.io.TextScoreReader.<init>(TextScoreReader.java:46)
    at de.saar.coli.irtg.experimental.astar.io.SerializedScoreReader.main(SerializedScoreReader.java:171)

Here are the graph comparisons which trigger this:

java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[n3<root>/--LEX-- -polarity-> explicitanon2/-; n3 -ARG1-> t<s>]
(s(), o()):[f<root>/--LEX-- -ARG0-> a<o>; f -ARG1-> c<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[n3<root>/--LEX-- -polarity-> explicitanon2/-; n3 -ARG1-> t<s>]
(snt2(), snt1()):[m<root>/--LEX-- -snt2-> p3<snt2>; m -snt1-> n<snt1>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[n3<root>/--LEX-- -polarity-> explicitanon2/-; n3 -ARG1-> t<s>]
(s(), o()):[f<root>/--LEX-- -ARG0-> a<o>; f -ARG1-> c<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[n3<root>/--LEX-- -polarity-> explicitanon2/-; n3 -ARG1-> t<s>]
(snt2(), snt1()):[m<root>/--LEX-- -snt2-> p3<snt2>; m -snt1-> n<snt1>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[n3<root>/--LEX-- -polarity-> explicitanon2/-; n3 -ARG1-> t<s>]
(s(), o()):[f<root>/--LEX-- -ARG0-> a<o>; f -ARG1-> c<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[n3<root>/--LEX-- -polarity-> explicitanon2/-; n3 -ARG1-> t<s>]
(snt2(), snt1()):[m<root>/--LEX-- -snt2-> p3<snt2>; m -snt1-> n<snt1>]
java.lang.ArrayIndexOutOfBoundsException: 2
(snt2(s_UNIFY_snt1())):[m<root>/--LEX-- -snt2-> p3<snt2>; m -snt1-> n<snt1>]
(s()):[i<root>/--LEX-- -polarity-> explicitanon2/-; i -ARG0-> i2<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(snt2(s_UNIFY_snt1())):[m<root>/--LEX-- -snt2-> p3<snt2>; m -snt1-> n<snt1>]
(s()):[i<root>/--LEX-- -polarity-> explicitanon2/-; i -ARG0-> i2<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(snt2(s_UNIFY_snt1())):[m<root>/--LEX-- -snt2-> p3<snt2>; m -snt1-> n<snt1>]
(s()):[i<root>/--LEX-- -polarity-> explicitanon2/-; i -ARG0-> i2<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(snt2(s_UNIFY_snt1())):[m<root>/--LEX-- -snt2-> p3<snt2>; m -snt1-> n<snt1>]
(s()):[i<root>/--LEX-- -polarity-> explicitanon2/-; i -ARG0-> i2<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(o()):[r2/--LEX-- -ARG3-> a2<o>; r2 -ARG0-> t<root>/thing]
(s(s_UNIFY_o())):[c<root>/--LEX-- -ARG2-> i2<o>; c -ARG1-> i<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(o()):[r2/--LEX-- -ARG3-> a2<o>; r2 -ARG0-> t<root>/thing]
(s(s_UNIFY_o())):[c<root>/--LEX-- -ARG2-> i2<o>; c -ARG1-> i<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(o()):[r2/--LEX-- -ARG3-> a2<o>; r2 -ARG0-> t<root>/thing]
(s(s_UNIFY_o())):[c<root>/--LEX-- -ARG2-> i2<o>; c -ARG1-> i<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(o()):[r2/--LEX-- -ARG3-> a2<o>; r2 -ARG0-> t<root>/thing]
(s(s_UNIFY_o())):[c<root>/--LEX-- -ARG2-> i2<o>; c -ARG1-> i<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[m<root>/--LEX-- -ARG1-> t<s>; m -ARG2-> t2/thing]
(s(), o()):[a2<root>/--LEX-- -ARG0-> p2<s>; a2 -ARG2-> r<o>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[m<root>/--LEX-- -ARG1-> t<s>; m -ARG2-> t2/thing]
(s(), o()):[e2<root>/--LEX-- -ARG1-> p4<o>; e2 -ARG1-> w2<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[m<root>/--LEX-- -ARG1-> t<s>; m -ARG2-> t2/thing]
(s(), o()):[a2<root>/--LEX-- -ARG0-> p2<s>; a2 -ARG2-> r<o>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[m<root>/--LEX-- -ARG1-> t<s>; m -ARG2-> t2/thing]
(s(), o()):[e2<root>/--LEX-- -ARG1-> p4<o>; e2 -ARG1-> w2<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[m<root>/--LEX-- -ARG1-> t<s>; m -ARG2-> t2/thing]
(s(), o()):[a2<root>/--LEX-- -ARG0-> p2<s>; a2 -ARG2-> r<o>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[m<root>/--LEX-- -ARG1-> t<s>; m -ARG2-> t2/thing]
(s(), o()):[e2<root>/--LEX-- -ARG1-> p4<o>; e2 -ARG1-> w2<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[m<root>/--LEX-- -ARG1-> t<s>; m -ARG2-> t2/thing]
(s(), o()):[a2<root>/--LEX-- -ARG0-> p2<s>; a2 -ARG2-> r<o>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[m<root>/--LEX-- -ARG1-> t<s>; m -ARG2-> t2/thing]
(s(), o()):[e2<root>/--LEX-- -ARG1-> p4<o>; e2 -ARG1-> w2<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(op2(), op22()):[a2<root>/--LEX-- -op2-> p<op2>; a2 -op2-> p2<op22>]
(s()):[i<root>/--LEX-- -polarity-> explicitanon2/-; i -ARG0-> i2<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(op2(), op22()):[a2<root>/--LEX-- -op2-> p<op2>; a2 -op2-> p2<op22>]
(s()):[i<root>/--LEX-- -polarity-> explicitanon2/-; i -ARG0-> i2<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(op2(), op22()):[a2<root>/--LEX-- -op2-> p<op2>; a2 -op2-> p2<op22>]
(s()):[i<root>/--LEX-- -polarity-> explicitanon2/-; i -ARG0-> i2<s>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[m<root>/--LEX-- -ARG1-> t<s>; m -ARG2-> t2/thing]
(s(), o()):[a2<root>/--LEX-- -ARG0-> p2<s>; a2 -ARG2-> r<o>]
java.lang.ArrayIndexOutOfBoundsException: 2
(s()):[m<root>/--LEX-- -ARG1-> t<s>; m -ARG2-> t2/thing]
(s(), o()):[e2<root>/--LEX-- -ARG1-> p4<o>; e2 -ARG1-> w2<s>]
alexanderkoller commented 4 years ago

I have temporarily changed SupertagWithType#equals to catch this exception, but it would be good to change that back once the root cause has been fixed.

jgroschwitz commented 4 years ago

I reproduced this with the first graph pair and added a test (testIso7 in SGraphTest, currently not in the active tests since it is still failing). I don't know what's happening here, upgrading to the newest JGraphT version may be best, although that will require quite some refactoring (the JGraphT interface changed). Let's look into it at a later point, for now I think we can treat the graphs as not equal.