(a) added a model file for the emnlp2013 run (b) small code changes

This commit is contained in:
Jonathan Berant 2013-11-03 09:47:42 -08:00
parent 4a0b920260
commit f8e06d466e
6 changed files with 41 additions and 30 deletions

View File

@ -36,6 +36,7 @@ src/edu/stanford/nlp/sempre/Dataset.java
src/edu/stanford/nlp/sempre/Learner.java
src/edu/stanford/nlp/sempre/Params.java
src/edu/stanford/nlp/sempre/FeatureVector.java
src/edu/stanford/nlp/sempre/FeatureMatcher.java
src/edu/stanford/nlp/sempre/Evaluation.java
# Parsing

View File

@ -30,6 +30,10 @@ lib/data/webquestions/dataset_11/webquestions.examples.test.json
lib/lucene/4.4/free917
lib/lucene/4.4/inexact
############################################################
# Model
lib/models/2174.exec
############################################################
# Grammars
data/emnlp2013.grammar

View File

@ -0,0 +1,28 @@
package edu.stanford.nlp.sempre;
public interface FeatureMatcher {
public boolean matches(String feature);
}
class AllFeatureMatcher implements FeatureMatcher {
private AllFeatureMatcher() { }
@Override
public boolean matches(String feature) { return true; }
public static final AllFeatureMatcher matcher = new AllFeatureMatcher();
}
class ExactFeatureMatcher implements FeatureMatcher {
private String match;
public ExactFeatureMatcher(String match) { this.match = match; }
@Override
public boolean matches(String feature) { return feature.equals(match); }
}
class DenotationFeatureMatcher implements FeatureMatcher {
@Override
public boolean matches(String feature) {
return feature.startsWith("denotation-size") ||
feature.startsWith("count-denotation-size");
}
public static final DenotationFeatureMatcher matcher = new DenotationFeatureMatcher();
}

View File

@ -6,34 +6,6 @@ import fig.basic.*;
import java.util.*;
// Used to select a subset of features (to update).
interface FeatureMatcher {
public boolean matches(String feature);
}
class AllFeatureMatcher implements FeatureMatcher {
private AllFeatureMatcher() { }
@Override
public boolean matches(String feature) { return true; }
public static final AllFeatureMatcher matcher = new AllFeatureMatcher();
}
class ExactFeatureMatcher implements FeatureMatcher {
private String match;
public ExactFeatureMatcher(String match) { this.match = match; }
@Override
public boolean matches(String feature) { return feature.equals(match); }
}
class DenotationFeatureMatcher implements FeatureMatcher {
@Override
public boolean matches(String feature) {
return feature.startsWith("denotation-size") ||
feature.startsWith("count-denotation-size");
}
public static final DenotationFeatureMatcher matcher = new DenotationFeatureMatcher();
}
/**
* A FeatureVector represents a mapping from feature (string) to value
* (double).

View File

@ -116,11 +116,17 @@ public class LanguageInfo {
public String lemmaPhrase(int start, int end) {
return sliceSequence(lemmaTokens, start, end);
}
public String posSeq(int start, int end) {
return sliceSequence(posTags, start, end);
}
public String nerSeq(int start, int end) {
return sliceSequence(nerTags, start, end);
}
private static String sliceSequence(List<String> items,
int start,
int end) {
if (start >= end) throw new RuntimeException("Bad indices");
if (start >= end) throw new RuntimeException("Bad indices, start="+start+", end="+end);
if (end - start == 1) return items.get(start);
StringBuilder out = new StringBuilder();
for (int i = start; i < end; i++) {

View File

@ -35,7 +35,7 @@ public class Params {
public static Options opts = new Options();
// Discriminative weights
HashMap<String, Double> weights = new HashMap<String, Double>();
public HashMap<String, Double> weights = new HashMap<String, Double>();
// For AdaGrad
Map<String, Double> sumSquaredGradients = new HashMap<String, Double>();