Beispiel #1
0
 /** Finds the lexical items used to produce the highest scoring parse. */
 public List getMaxLexEntries() {
   List result = new LinkedList();
   for (ParseResult p : bestParses) {
     result.addAll(p.getLexEntries());
   }
   return result;
 }
Beispiel #2
0
 /** Finds the lexical items used to produce the highest scoring parse with semantics sem. */
 public List getMaxLexEntriesFor(Exp sem) {
   List result = new LinkedList();
   for (ParseResult p : findBestParses(allParses, sem)) {
     result.addAll(p.getLexEntries());
   }
   return result;
 }
Beispiel #3
0
 /** Returns the features for the highest-score current parse(s). */
 public HashVector getFeats() {
   HashVector result = new HashVector();
   // result.reset(theta.size(),0.0);
   for (ParseResult p : bestParses) p.getFeats(result);
   if (bestParses.size() > 1) result.divideBy(bestParses.size());
   return result;
 }
Beispiel #4
0
 public boolean hasExp(Exp sem) {
   for (ParseResult p : allParses) {
     if (p.getExp().equals(sem)) {
       return true;
     }
   }
   return false;
 }
Beispiel #5
0
 /** Returns the features for the highest-score current parse with semantics that equal sem. */
 public HashVector getFeats(Exp sem) {
   HashVector result = new HashVector();
   List<ParseResult> pr = findBestParses(allParses, sem);
   for (ParseResult p : pr) {
     p.getFeats(result);
   }
   if (pr.size() > 1) result.divideBy(pr.size());
   return result;
 }
Beispiel #6
0
 private List<ParseResult> findBestParses(List<ParseResult> all, Exp e) {
   List<ParseResult> best = new LinkedList<ParseResult>();
   double bestScore = -Double.MAX_VALUE;
   for (ParseResult p : all) {
     if (p.getExp().inferType() != null) {
       if ((e == null || p.getExp().equals(e))) {
         if (p.getScore() == bestScore) best.add(p);
         if (p.getScore() > bestScore) {
           bestScore = p.getScore();
           best.clear();
           best.add(p);
         }
       }
     }
   }
   return best;
 }
Beispiel #7
0
 private List<ParseResult> removeRepeats(List<ParseResult> all) {
   System.out.println("----------------------- all.size equals to --------------" + all.size());
   List<ParseResult> bestList = new LinkedList<ParseResult>();
   for (int i = 0; i < all.size(); i++) {
     ParseResult e_i = all.get(i);
     boolean best = true;
     for (int j = i + 1; j < all.size(); j++) {
       ParseResult e_j = all.get(j);
       if (e_i.getExp().equals(e_j.getExp()) && e_i.getScore() <= e_j.getScore()) {
         best = false;
         break;
       }
     }
     if (best) bestList.add(e_i);
   }
   return bestList;
 }