private void extractAllFeats ( FgExampleList data , FactorTemplateList templates ) { // Create a "no-op" counter. IFgModel counts = new IFgModel ( ) { @ Override public void addAfterScaling ( FeatureVector fv , double multiplier ) { } @ Override public void add ( int feat , double addend ) { } } ; // Loop over all factors in the dataset. for ( int i = 0 ; i < data . size ( ) ; i ++ ) { if ( i % 1000 == 0 ) { log . debug ( "Processing example: " + i ) ; } LFgExample ex = data . get ( i ) ; FactorGraph fgLat = MarginalLogLikelihood . getFgLat ( ex . getFactorGraph ( ) , ex . getGoldConfig ( ) ) ; // Create a "no-op" inferencer, which returns arbitrary marginals. NoOpInferencer inferencer = new NoOpInferencer ( ex . getFactorGraph ( ) ) ; for ( int a = 0 ; a < ex . getFactorGraph ( ) . getNumFactors ( ) ; a ++ ) { Factor f = fgLat . getFactor ( a ) ; if ( f instanceof ObsFeatureCarrier && f instanceof TemplateFactor ) { // For each observation function extractor. int t = templates . getTemplateId ( ( TemplateFactor ) f ) ; if ( t != - 1 ) { ( ( ObsFeatureCarrier ) f ) . getObsFeatures ( ) ; } } else { // For each standard factor. f = ex . getFactorGraph ( ) . getFactor ( a ) ; if ( f instanceof GlobalFactor ) { ( ( GlobalFactor ) f ) . addExpectedPartials ( counts , 0 , inferencer , a ) ; } else { VarTensor marg = inferencer . getMarginalsForFactorId ( a ) ; f . addExpectedPartials ( counts , marg , 0 ) ; } } } } }
Loops through all examples to create the features thereby ensuring that the FTS are initialized .