Examples of LanguageInfo


Examples of com.google.refine.expr.MetaParser.LanguageInfo

            }
            writer.endObject();
           
            writer.key("scripting"); writer.object();
            for (String languagePrefix : MetaParser.getLanguagePrefixes()) {
                LanguageInfo info = MetaParser.getLanguageInfo(languagePrefix);
               
                writer.key(languagePrefix);
                writer.object();
                    writer.key("name"); writer.value(info.name);
                    writer.key("defaultExpression"); writer.value(info.defaultExpression);
View Full Code Here

Examples of edu.stanford.nlp.sempre.LanguageInfo

    if(nextTrie!=null)
      nextNodes.add(nextTrie);
  }

  private RuleApplication generateApplications(LanguageInfo antecedent, int i, int j, List<WordInfo> rhsMatch, SubstitutableSyntacticRule rule) {
    LanguageInfo consequent = new LanguageInfo();
    consequent.addSpan(antecedent, 0, i);
    consequent.addWordInfos(rhsMatch);
    consequent.addSpan(antecedent, j, antecedent.numTokens());
    RuleApplication application = new RuleApplication(antecedent, consequent, new ApplicationInfo(SYNT_SUBST, rule.toString()));
    FeatureVector fv = new FeatureVector();
    fv.add(SYNT_SUBST, rule.toString());
    fv.add(SYNT_SUBST, "score" ,rule.count);
    application.addFeatures(fv);
View Full Code Here

Examples of edu.stanford.nlp.sempre.LanguageInfo

  public static void main(String[] args) {
    opts.verbose=3;
    SyntacticRuleSet.opts.rulesetPath="/Users/jonathanberant/Research/temp/syntactic-rules.retagged.sorted.txt";
    SyntacticRuleSet srt = new SyntacticRuleSet();
    LanguageInfo antecedent = new LanguageInfo();
    antecedent.addWordInfo(new WordInfo("where", "where", "WDT", "O", "O"));
    antecedent.addWordInfo(new WordInfo("was", "be", "VBD", "O", "O"));
    antecedent.addWordInfo(new WordInfo("obama", "obama", "NNP", "PERSON", "O"));
    antecedent.addWordInfo(new WordInfo("birth", "birth", "NN", "O", "O"));
    antecedent.addWordInfo(new WordInfo("place", "place", "NN", "O", "O"));

    LanguageInfo target = new LanguageInfo();
    target.addWordInfo(new WordInfo("where", "where", "WDT", "O", "O"));
    target.addWordInfo(new WordInfo("was", "be", "VBD", "O", "O"));
    target.addWordInfo(new WordInfo("obama", "obama", "NNP", "PERSON", "O"));
    target.addWordInfo(new WordInfo("'s", "'s", "POS", "O", "O"));
    target.addWordInfo(new WordInfo("place", "place", "NN", "O", "O"));
    target.addWordInfo(new WordInfo("of", "of", "IN", "O", "O"));
    target.addWordInfo(new WordInfo("birth", "birth", "NN", "O", "O"));
    srt.apply(antecedent, target);
  }
View Full Code Here

Examples of edu.stanford.nlp.sempre.LanguageInfo

  }

  //TODO reuse code in generateApplications
  protected List<RuleApplication> generateApplications(LanguageInfo antecedent, LangExpMatch match, LanguageInfo target) {

    LanguageInfo res = new LanguageInfo();
    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(RULE,""));
View Full Code Here

Examples of edu.stanford.nlp.sempre.LanguageInfo

    return Json.readValueHard(json, ParsingExample.class);
  }

  public void preprocess() {
    if (this.languageInfo == null)
      this.languageInfo = new LanguageInfo();
    this.languageInfo.analyze(this.utterance);
    this.log();
  }
View Full Code Here

Examples of edu.stanford.nlp.sempre.LanguageInfo

      throw new RuntimeException("In a deletion rules there must be exactly three items on the rhs");
  }

  protected List<RuleApplication> generateApplications(LanguageInfo antecedent, LangExpMatch match, LanguageInfo target) {

    LanguageInfo res = new LanguageInfo();
    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,
View Full Code Here

Examples of edu.stanford.nlp.sempre.LanguageInfo

  protected List<RuleApplication> generateApplications(LanguageInfo antecedent, LangExpMatch match, LanguageInfo target) {

    List<RuleApplication> res = new LinkedList<RuleApplication>();
    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);
        }
      }
      RuleApplication application = new RuleApplication(antecedent, consequent,
          new ApplicationInfo(SUBST, antecedent.lemmaPhrase(match.get(1).start, match.get(1).end)+"-->"+
              target.lemmaPhrase(targetInterval.start, targetInterval.end)));
View Full Code Here

Examples of edu.stanford.nlp.sempre.LanguageInfo

    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) {
      LanguageInfo consequent = new LanguageInfo();
      if(i>=matchedInterval.start && i <=matchedInterval.end) continue;
      if(i<matchedInterval.start) {
        consequent.addSpan(antecedent, 0, i);
        consequent.addSpan(antecedent, matchedInterval.start,matchedInterval.end);
        consequent.addSpan(antecedent, i,matchedInterval.start);
        consequent.addSpan(antecedent, matchedInterval.end,antecedent.numTokens());
      }
      else if(i>matchedInterval.end) {
        consequent.addSpan(antecedent, 0, matchedInterval.start);
        consequent.addSpan(antecedent, matchedInterval.end,i);
        consequent.addSpan(antecedent, matchedInterval.start,matchedInterval.end);
        consequent.addSpan(antecedent, i,antecedent.numTokens());
      }
      RuleApplication application = new RuleApplication(antecedent, consequent,
          new ApplicationInfo(MOVE,antecedent.lemmaPhrase(matchedInterval.start, matchedInterval.end)));
      application.addFeatures(featurizeMovedSpan(antecedent,matchedInterval));
      res.add(application);
View Full Code Here

Examples of edu.stanford.nlp.sempre.LanguageInfo

    for(String rhsLemmaSpan: rhsLemmaSpans.keySet()) {
      if(rhsCandidates.containsKey(rhsLemmaSpan)) {
       
        int targetStart = rhsLemmaSpans.get(rhsLemmaSpan).first;
        int targetEnd = rhsLemmaSpans.get(rhsLemmaSpan).second;         
        LanguageInfo consequent = generateConsequent(antecedent,matchStart,matchEnd,
            target, targetStart,targetEnd);
        RuleApplication application = new RuleApplication(antecedent, consequent,
            new ApplicationInfo(PHRASE_TABLE, lhsPhrase+"-->"+rhsLemmaSpan));
        application.addFeatures(featureizePhraseTablespan(lhsPhrase,rhsLemmaSpan,rhsCandidates.get(rhsLemmaSpan),
            antecedent,matchStart,matchEnd,target,targetStart,targetEnd));
View Full Code Here

Examples of edu.stanford.nlp.sempre.LanguageInfo

  }

  private LanguageInfo generateConsequent(LanguageInfo antecedent,
      int matchStart, int matchEnd, LanguageInfo target, int targetStart,
      int targetEnd) {
    LanguageInfo res = new LanguageInfo();
    res.addSpan(antecedent, 0, matchStart);
    res.addSpan(target, targetStart, targetEnd);
    res.addSpan(antecedent, matchEnd, antecedent.numTokens());
    return res;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.