Package edu.stanford.nlp.sempre.fbalignment.utils

Examples of edu.stanford.nlp.sempre.fbalignment.utils.DoubleContainer


    Map<Context,DoubleContainer> context1Rules = rulesMap.get(context1);
    if(context1Rules==null) {
      context1Rules = new HashMap<Context, DoubleContainer>();
      rulesMap.put(context1, context1Rules);
    }
    DoubleContainer count = context1Rules.get(context2);
    if(count==null) {
      count = new DoubleContainer(0.0);
      context1Rules.put(context2, count);
    }
    count.set(count.value()+1);
  }
View Full Code Here


    return new Interval(start, end);
  }

  public DoubleContainer match(Context questionContext, Context candidate) {
    if(rulesMap.containsKey(questionContext)){
      return MapUtils.get(rulesMap.get(questionContext),candidate,new DoubleContainer(0.0));
    }
    return new DoubleContainer(0.0);
  }
View Full Code Here

      throw new RuntimeException("Can not increment a normalized context mapper");

    MapUtils.putIfAbsent(contextToBinaryCounter, c, new HashMap<Formula,DoubleContainer>());
    Map<Formula,DoubleContainer> formulaMap = contextToBinaryCounter.get(c); //guaranteed to exist

    MapUtils.putIfAbsent(formulaMap, f, new DoubleContainer(0.0));
    DoubleContainer currValue = formulaMap.get(f);
    currValue.inc(value);

  }
View Full Code Here

    for(Context candidate: candidates) {
      if(candidate.equals(questionContext)) {
        LogInfo.logs("RuleTransformationModel: Exact match",questionContext,candidate);
        res.clear();
        res.put(candidate, new DoubleContainer(1.0));
        break;
      }
      double matchCount = rules.match(questionContext,candidate).value();
      if(matchCount>0.0) {
        LogInfo.logs("RuleTransformationModel: question=%s, match=%s, score=%s",questionContext,candidate,matchCount);
        res.put(candidate, new DoubleContainer(matchCount));
      }
    }
    MathUtils.normalizeDoubleMap(res);
    return CollectionUtils.doubleContainerToDoubleMap(res);
  }
View Full Code Here

    //construct formula map   
    for (Derivation deriv : predDerivations) {
      if (aggregationMap.containsKey(deriv.formula))
        aggregationMap.get(deriv.formula).getSecond().inc(deriv.prob);
      else
        aggregationMap.put(deriv.formula, Pair.newPair(Pair.newPair(deriv.formula, deriv.value), new DoubleContainer(deriv.prob)));
    }

    List<Pair<Pair<Formula, Value>, DoubleContainer>> formulaList = new ArrayList<Pair<Pair<Formula, Value>, DoubleContainer>>(aggregationMap.values());
    double sum = 0.0;
    for (Pair<Pair<Formula, Value>, DoubleContainer> pair : formulaList)
View Full Code Here

    for (Derivation deriv : predDerivations) {
      String strValue = deriv.value != null ? deriv.value.toString() : "-UNKNOWN-";
      if (aggregationMap.containsKey(strValue))
        aggregationMap.get(strValue).getSecond().inc(deriv.prob);
      else
        aggregationMap.put(strValue, new Pair<Value, DoubleContainer>(deriv.value, new DoubleContainer(deriv.prob)));
    }
    List<Pair<Value, DoubleContainer>> valueList = new ArrayList<Pair<Value, DoubleContainer>>(aggregationMap.values());
    double sum = 0.0;
    for (Pair<Value, DoubleContainer> pair : valueList)
      sum += pair.getSecond().value();
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.sempre.fbalignment.utils.DoubleContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.