コード例 #1
0
 private String getMaxHiddenVariable(String frame, int[] intTokNums, String[][] data) {
   THashSet<String> hiddenUnits = mFrameMap.get(frame);
   String maxHV = null;
   double maxVal = -Double.MAX_VALUE;
   DependencyParse parse = DependencyParse.processFN(data, 0.0);
   for (String unit : hiddenUnits) {
     FeatureExtractor featex = new FeatureExtractor();
     IntCounter<String> valMap =
         featex.extractFeaturesLessMemory(
             frame,
             intTokNums,
             unit,
             data,
             "test",
             mRelatedWordsForWord,
             mRevisedRelationsMap,
             mHVLemmas,
             parse);
     Set<String> features = valMap.keySet();
     double featSum = 0.0;
     for (String feat : features) {
       double val = valMap.getT(feat);
       int ind = localA.get(feat);
       double paramVal = V[ind].exponentiate();
       double prod = val * paramVal;
       featSum += prod;
     }
     double expVal = Math.exp(featSum);
     if (expVal > maxVal) {
       maxVal = expVal;
       maxHV = unit;
     }
   }
   return maxHV;
 }
コード例 #2
0
 private double getValueForFrame(String frame, int[] intTokNums, String[][] data) {
   THashSet<String> hiddenUnits = mFrameMap.get(frame);
   double result = 0.0;
   DependencyParse parse = DependencyParse.processFN(data, 0.0);
   for (String unit : hiddenUnits) {
     IntCounter<String> valMap = null;
     FeatureExtractor featex = new FeatureExtractor();
     if (clusterMap == null) {
       valMap =
           featex.extractFeaturesLessMemory(
               frame,
               intTokNums,
               unit,
               data,
               "test",
               mRelatedWordsForWord,
               mRevisedRelationsMap,
               mHVLemmas,
               parse);
     } else { // not supported
       valMap =
           featex.extractFeaturesWithClusters(
               frame, intTokNums, unit, data, mWNR, "test", null, null, parse, clusterMap, K);
     }
     Set<String> features = valMap.keySet();
     double featSum = 0.0;
     for (String feat : features) {
       double val = valMap.getT(feat);
       int ind = localA.get(feat);
       double paramVal = V[ind].exponentiate();
       double prod = val * paramVal;
       featSum += prod;
     }
     double expVal = Math.exp(featSum);
     result += expVal;
   }
   return result;
 }