public static List < GrammaticalRelation > getListGrammaticalRelation ( TreeGraphNode gov , TreeGraphNode dep ) { List < GrammaticalRelation > list = new ArrayList < GrammaticalRelation > ( ) ; TreeGraphNode govH = gov . highestNodeWithSameHead ( ) ; TreeGraphNode depH = dep . highestNodeWithSameHead ( ) ; /*System.out.println("Extra gov node " + gov); System.out.println("govH " + govH); System.out.println("dep node " + dep); System.out.println("depH " + depH);*/ Set < Class < ? extends GrammaticalRelationAnnotation > > arcLabels = govH . arcLabelsToNode ( depH ) ; //System.out.println("arcLabels: " + arcLabels); if ( dep != depH ) { Set < Class < ? extends GrammaticalRelationAnnotation > > arcLabels2 = govH . arcLabelsToNode ( dep ) ; //System.out.println("arcLabels2: " + arcLabels2); arcLabels . addAll ( arcLabels2 ) ; } //System.out.println("arcLabels: " + arcLabels); for ( Class < ? extends GrammaticalRelationAnnotation > arcLabel : arcLabels ) { if ( arcLabel != null ) { GrammaticalRelation reln2 = GrammaticalRelation . getRelation ( arcLabel ) ; if ( ! list . isEmpty ( ) ) { for ( int i = 0 ; i < list . size ( ) ; i ++ ) { GrammaticalRelation gr = list . get ( i ) ; //if the element in the list is an ancestor of the current relation, replace it if ( gr . isAncestor ( reln2 ) ) { int index = list . indexOf ( gr ) ; list . set ( index , reln2 ) ; } //if the relation is not an ancestor of an element in the list, we add the relation else if ( ! reln2 . isAncestor ( gr ) ) { list . add ( reln2 ) ; } } } else { list . add ( reln2 ) ; } } } //System.out.println("in list " + list); return list ; }
Get a list of GrammaticalRelation between gov and dep . Useful for getting extra dependencies in which two nodes can be linked by multiple arcs .