public static Pair<int[],double[]> convert(Set<Feature> features,Lexicon lexicon,boolean trainingMode){
  TIntDoubleHashMap fMap=new TIntDoubleHashMap(features.size());
  for (  Feature feature : features) {
    final int featureId=FeatureUtilities.getFeatureId(lexicon,trainingMode,feature);
    if (featureId < 0)     continue;
    double value=feature.getValue() + fMap.get(featureId);
    fMap.put(featureId,value);
  }
  int[] idsOriginal=fMap.keys();
  int[] ids=new int[idsOriginal.length];
  System.arraycopy(idsOriginal,0,ids,0,ids.length);
  Arrays.sort(ids);
  double[] vals=new double[fMap.size()];
  int count=0;
  for (  int key : ids) {
    vals[count++]=fMap.get(key);
  }
  return new Pair<>(ids,vals);
}

public static Pair < int [ ] , double [ ] > convert ( Set < Feature > features , Lexicon lexicon , boolean trainingMode ) { TIntDoubleHashMap fMap = new TIntDoubleHashMap ( features . size ( ) ) ; for ( Feature feature : features ) { final int featureId = FeatureUtilities . getFeatureId ( lexicon , trainingMode , feature ) ; if ( featureId < 0 ) continue ; double value = feature . getValue ( ) + fMap . get ( featureId ) ; fMap . put ( featureId , value ) ; } int [ ] idsOriginal = fMap . keys ( ) ; int [ ] ids = new int [ idsOriginal . length ] ; System . arraycopy ( idsOriginal , 0 , ids , 0 , ids . length ) ; Arrays . sort ( ids ) ; double [ ] vals = new double [ fMap . size ( ) ] ; int count = 0 ; for ( int key : ids ) { vals [ count ++ ] = fMap . get ( key ) ; } return new Pair < > ( ids , vals ) ; }
convert a feature set into a pair of arrays of integers and doubles by looking up the feature name in the provided lexicon .
