private List < AgigaTypedDependency > parseDependencies ( VTDNav vn , DependencyForm form ) throws NavException , PilotException { require ( vn . matchElement ( AgigaConstants . SENTENCE ) ) ; // Move to the <basic-deps> tag require ( vn . toElement ( VTDNav . FC , form . getXmlTag ( ) ) ) ; List < AgigaTypedDependency > agigaDeps = new ArrayList < AgigaTypedDependency > ( ) ; // Loop through the dep tags AutoPilot basicDepRelAp = new AutoPilot ( vn ) ; basicDepRelAp . selectElement ( AgigaConstants . DEP ) ; while ( basicDepRelAp . iterate ( ) ) { // Read the type, governor, and dependent String type = vn . toString ( vn . getAttrVal ( AgigaConstants . DEP_TYPE ) ) ; require ( vn . toElement ( VTDNav . FC , AgigaConstants . GOVERNOR ) ) ; int governorId = vn . parseInt ( vn . getText ( ) ) ; require ( vn . toElement ( VTDNav . NS , AgigaConstants . DEPENDENT ) ) ; int dependentId = vn . parseInt ( vn . getText ( ) ) ; log . finer ( String . format ( "\tdep type=%s\t%d-->%d" , type , governorId , dependentId ) ) ; // Subtract one, since the tokens are one-indexed in the XML but // zero-indexed in this API AgigaTypedDependency agigaDep = new AgigaTypedDependency ( type , governorId - 1 , dependentId - 1 ) ; agigaDeps . add ( agigaDep ) ; } return agigaDeps ; }
Assumes the position of vn is at a sent tag