diff --git a/release-code.files b/release-code.files index cd8a59a..4653023 100644 --- a/release-code.files +++ b/release-code.files @@ -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 diff --git a/release-emnlp2013.files b/release-emnlp2013.files index 3c6b8d5..81ef39d 100644 --- a/release-emnlp2013.files +++ b/release-emnlp2013.files @@ -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 diff --git a/src/edu/stanford/nlp/sempre/FeatureMatcher.java b/src/edu/stanford/nlp/sempre/FeatureMatcher.java new file mode 100644 index 0000000..897a75f --- /dev/null +++ b/src/edu/stanford/nlp/sempre/FeatureMatcher.java @@ -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(); +} diff --git a/src/edu/stanford/nlp/sempre/FeatureVector.java b/src/edu/stanford/nlp/sempre/FeatureVector.java index 90f1cf4..cd638e7 100644 --- a/src/edu/stanford/nlp/sempre/FeatureVector.java +++ b/src/edu/stanford/nlp/sempre/FeatureVector.java @@ -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). diff --git a/src/edu/stanford/nlp/sempre/LanguageInfo.java b/src/edu/stanford/nlp/sempre/LanguageInfo.java index aaf18e5..c7c2839 100644 --- a/src/edu/stanford/nlp/sempre/LanguageInfo.java +++ b/src/edu/stanford/nlp/sempre/LanguageInfo.java @@ -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 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++) { diff --git a/src/edu/stanford/nlp/sempre/Params.java b/src/edu/stanford/nlp/sempre/Params.java index 459a1f0..85af780 100644 --- a/src/edu/stanford/nlp/sempre/Params.java +++ b/src/edu/stanford/nlp/sempre/Params.java @@ -35,7 +35,7 @@ public class Params { public static Options opts = new Options(); // Discriminative weights - HashMap weights = new HashMap(); + public HashMap weights = new HashMap(); // For AdaGrad Map sumSquaredGradients = new HashMap();