public static int [ ] getParents ( int n , VarConfig vc ) { int [ ] parents = new int [ n ] ; Arrays . fill ( parents , - 2 ) ; for ( Var v : vc . getVars ( ) ) { if ( v instanceof LinkVar ) { LinkVar link = ( LinkVar ) v ; if ( vc . getState ( v ) == LinkVar . TRUE ) { if ( parents [ link . getChild ( ) ] != - 2 ) { throw new IllegalStateException ( "Multiple parents defined for the same child. Is this VarConfig for only one example?" ) ; } parents [ link . getChild ( ) ] = link . getParent ( ) ; } } } return parents ; }
Extracts the parents as defined by a variable assignment for a single sentence .