Package edu.stanford.nlp.sempre.paraphrase

Examples of edu.stanford.nlp.sempre.paraphrase.Interval


    for(Object obj: rhs) {
      if(obj instanceof WordInfo) {
        res.addWordInfo(((WordInfo) obj));
      }
      else if(obj instanceof Integer) {
        Interval matchingInterval = match.get(((Integer) obj));
        res.addSpan(antecedent, matchingInterval.start, matchingInterval.end);
      }
      else
        throw new RuntimeException("Rhs should be a list of wordinfo or integer keys to intervals only");
    }
    RuleApplication application = new RuleApplication(antecedent, res,new ApplicationInfo(DELETE,
        antecedent.lemmaPhrase(match.get(1).start, match.get(1).end)));
    application.addFeatures(featurizeDeletedSpan(new Interval(match.get(1).start,match.get(1).end),antecedent))
    return Collections.singletonList(application);
  }
View Full Code Here


    List<Interval> targetIntervals = generateConsequentIntervals(antecedent,match,target); //finding all possible substitutions in the target
    for(Interval targetInterval: targetIntervals) {
      LanguageInfo consequent = new LanguageInfo();
      for(int i = 0; i < 3; ++i) {
        if(i==0 || i==2) {
          Interval matchingInterval = match.get(i);
          consequent.addSpan(antecedent, matchingInterval.start, matchingInterval.end);
        }
        else { //i==1
          consequent.addSpan(target, targetInterval.start, targetInterval.end);
        }
View Full Code Here

    //span 1 candidates
    for(int i = 0; i < target.numTokens(); ++i) {
      String targetPos = target.posTags.get(i);
      String targetLemma = target.lemmaPhrase(i, i+1);
      if(ParaphraseUtils.posCompatible(antecedentPos, targetPos) && !antecedentLemma.equals(targetLemma)) {
        res.add(new Interval(i,i+1));
      }
    }
    //span 2 candidates
    if(LanguageUtils.isNN(antecedentPos)) {
      for(int i = 0; i < target.numTokens()-1; ++i) {
        String targetLemma = target.lemmaPhrase(i, i+2);
        if(LanguageUtils.isNN(target.posTags.get(i)) && LanguageUtils.isNN(target.posTags.get(i+1))  && !antecedentLemma.equals(targetLemma))
          res.add(new Interval(i,i+2));
      }
    }
    return res;
  }
View Full Code Here

   * Move any phrase that exists in the target
   */
  protected List<RuleApplication> generateApplications(LanguageInfo antecedent, LangExpMatch match, LanguageInfo target) {

    List<RuleApplication> res = new LinkedList<RuleApplication>();
    Interval matchedInterval = match.get(1);
    String movedPhrase = antecedent.lemmaPhrase(matchedInterval.start, matchedInterval.end); //we know that 1 is the index moved
    if(!target.lemmaPhrase(0, target.numTokens()).contains(movedPhrase)) //don't move things that are not in the target
      return res;

    for(int i = 0; i < antecedent.numTokens(); ++i) {
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.sempre.paraphrase.Interval

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.