private ILabel processNode ( INode currentNode , ArrayList < ILabel > pathToRootPhrases ) throws ContextPreprocessorException { if ( debugLabels ) { log . debug ( "preprocessing node: " + currentNode . getNodeData ( ) . getId ( ) + ", label: " + currentNode . getNodeData ( ) . getName ( ) ) ; } // reset old preprocessing currentNode . getNodeData ( ) . setcLabFormula ( "" ) ; currentNode . getNodeData ( ) . setcNodeFormula ( "" ) ; while ( 0 < currentNode . getNodeData ( ) . getACoLCount ( ) ) { currentNode . getNodeData ( ) . removeACoL ( 0 ) ; } String label = currentNode . getNodeData ( ) . getName ( ) ; ILabel result = new Label ( label ) ; result . setContext ( pathToRootPhrases ) ; try { pipeline . process ( result ) ; //should contain only token indexes. including not recognized, but except closed class tokens. //something like // 1 & 2 // 1 & (3 | 4) String formula = result . getFormula ( ) ; currentNode . getNodeData ( ) . setIsPreprocessed ( true ) ; //create acols. one acol for each concept (meaningful) token //non-concept tokens should not make it up to a formula. String [ ] tokenIndexes = formula . split ( "[ ()&|~]" ) ; Set < String > indexes = new HashSet < String > ( Arrays . asList ( tokenIndexes ) ) ; List < IToken > tokens = result . getTokens ( ) ; for ( int i = 0 ; i < tokens . size ( ) ; i ++ ) { IToken token = tokens . get ( i ) ; String tokenIdx = Integer . toString ( i ) ; if ( indexes . contains ( tokenIdx ) ) { IAtomicConceptOfLabel acol = currentNode . getNodeData ( ) . createACoL ( ) ; acol . setId ( i ) ; acol . setToken ( token . getText ( ) ) ; acol . setLemma ( token . getLemma ( ) ) ; for ( ISense sense : token . getSenses ( ) ) { acol . addSense ( sense ) ; } currentNode . getNodeData ( ) . addACoL ( acol ) ; } } //prepend all token references with node id formula = formula . replaceAll ( "(\\d+)" , currentNode . getNodeData ( ) . getId ( ) + ".$1" ) ; formula = formula . trim ( ) ; //set it to the node currentNode . getNodeData ( ) . setcLabFormula ( formula ) ; } catch ( PipelineComponentException e ) { if ( log . isEnabledFor ( Level . WARN ) ) { log . warn ( "Falling back to heuristic parser for label (" + result . getText ( ) + "): " + e . getMessage ( ) , e ) ; fallbackCount ++ ; dcp . processNode ( currentNode ) ; } } return result ; }
Converts current node label into a formula using path to root as a context