mirror of https://github.com/percyliang/sempre
(a) added a model file for the emnlp2013 run (b) small code changes
This commit is contained in:
parent
4a0b920260
commit
f8e06d466e
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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).
|
||||
|
|
|
|||
|
|
@ -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++) {
|
||||
|
|
|
|||
|
|
@ -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>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue