Package fig.basic

Examples of fig.basic.IntPair


    for(int i = 0; i < nerTags.size(); ++i) {
      String currTag = nerTags.get(i);
      if(currTag.equals("O")) {
        if(!prevTag.equals("O")) {
          res.add(new IntPair(start,i));
          start=-1;
        }
      }
      else { //currNe is not "O"
        if(!currTag.equals(prevTag)) {
          if(!prevTag.equals("O")) {
            res.add(new IntPair(start,i));
          }
          start=i;
        }
      }
      prevTag = currTag;
    }
    if(start!=-1)
      res.add(new IntPair(start,nerTags.size()));
    return res;
  }
View Full Code Here


        if(!LanguageUtils.isProperNoun(prevTag))
          start=i;
      }
      else { //curr tag is not proper noun
        if(LanguageUtils.isProperNoun(prevTag)) {
          res.add(new IntPair(start,i));
          start=-1;
        }
      }
      prevTag = currTag;
    }
    if(start!=-1)
      res.add(new IntPair(start,posTags.size()));
    return res;
  }
View Full Code Here

  public Map<String,IntPair> getLemmaSpans() {
    if(lemmaSpans==null) {
      lemmaSpans = new HashMap<String,IntPair>();
      for(int i = 0; i < numTokens()-1; ++i) {
        for(int j = i+1; j < numTokens(); ++j)
          lemmaSpans.put(lemmaPhrase(i, j),new IntPair(i,j));
      }
    }
    return lemmaSpans;
  }
View Full Code Here

      UnaryFormulaInfo uInfo =  fbFormulasInfo.getUnaryInfo(type1Formula);
      if(uInfo!=null) {
        for(String description: uInfo.descriptions) {
          if(validDescription(description)) {
            List<String> descriptionTokens = Arrays.asList(description.split("\\s+"));
            IntPair unarySpan = getUnarySpan(lInfo); //where should we match the description
            if(ParaphraseUtils.matchLists(lInfo.tokens.subList(unarySpan.first, unarySpan.second), descriptionTokens) ||
                ParaphraseUtils.matchLists(lInfo.lemmaTokens.subList(unarySpan.first, unarySpan.second), descriptionTokens)) {
              FormulaGenerationInfo fInfo =
                  new FormulaGenerationInfo(inFgInfo.bInfo, inFgInfo.injectedInfo, inFgInfo.entityInfo1, inFgInfo.entityInfo2, uInfo,
                      inFgInfo.isCount,inFgInfo.isInject,true);
View Full Code Here

    return res;
  }

  private IntPair getUnarySpan(LanguageInfo languageInfo) {
    if(!(languageInfo.lemmaTokens.get(0).equals("what") || languageInfo.lemmaTokens.get(0).equals("which")))
      return new IntPair();
    int start=1, end=1;
    for(; end < languageInfo.numTokens(); ++end) {
      if(languageInfo.posTags.get(end).startsWith("V"))
        break;
    }
    return new IntPair(start,end);
  }
View Full Code Here

  private void findInjectedTimeEntities(LanguageInfo lInfo, IntPair excludedSpan,
      List<EntityInfo> res) {
    for(int i = 0; i < lInfo.tokens.size(); i++) {
      if(lInfo.isNumberAndDate(i)) {
        IntPair span = new IntPair(i,i+1);
        if(ParaphraseUtils.intervalIntersect(span, excludedSpan))
          continue;
        String token = lInfo.tokens.get(i);
        if(DateValue.parseDateValue(token).year!=-1) {
          EntityInfo entityInfo = new EntityInfo(token, new ValueFormula<DateValue>(DateValue.parseDateValue(token)),0,span);
View Full Code Here

          LogInfo.logs("Retrieving: entry=%s",entityDesc);
        List<EntityLexicalEntry> entries = getEntityEntries(entityDesc);
        if(entries.isEmpty())
          entries = getEntityEntries(entityLemmas);
        for(EntityLexicalEntry entry: entries) {
          res.add(Pair.newPair(new IntPair(i, j), entry));
        }
      }
    }
  }
View Full Code Here

    if(res.isEmpty()) {
      for(int i = 0; i < lInfo.numTokens(); i++) {
        if(LanguageUtils.isEntity(lInfo, i)) {
          List<EntityLexicalEntry> entries = getEntityEntries(lInfo.tokens.get(i));
          for(EntityLexicalEntry entry: entries)
            res.add(Pair.newPair(new IntPair(i,i+1), entry));
        }
      }
    }
    //if can't try all content words
    if(res.isEmpty()) {
      for(int i = 0; i < lInfo.numTokens(); i++) {
        if(LanguageUtils.isContentWord(lInfo.getCanonicalPos(i))) {
          List<EntityLexicalEntry> entries = getEntityEntries(lInfo.tokens.get(i));
          for(EntityLexicalEntry entry: entries)
            res.add(Pair.newPair(new IntPair(i,i+1), entry));
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of fig.basic.IntPair

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.