(a) add mode esslli_2016 in pull-dependencies and run file (b) add option to load naiveknowledgegraph from interactive mode

This commit is contained in:
Jonathan Berant 2016-08-06 14:19:45 -07:00
parent 114ee52462
commit 032e66ee26
5 changed files with 39 additions and 2 deletions

View File

@ -189,6 +189,9 @@ addModule('overnight', 'Creating a parser for multiple domains', lambda {
pull('/u/nlp/data/semparse/overnight/calendar/eval/calendar.test.turk.examples', 'data/overnight/', {:symlink => true})
})
addModule('esslli_2016', 'Data for ESSLLI 2016 semantic parsing class', lambda {
pull('/u/nlp/data/semparse/esslli_2016/', 'data/esslli_2016/', {:symlink => true})
})
############################################################

8
run
View File

@ -457,6 +457,14 @@ addMode('simple-sparql', 'Simple shell for querying SPARQL', lambda { |e| l(
o('Main.interactive'),
nil) })
addMode('simple-lambdadcs', 'Simple shell for querying with the LambdaDCSExecutor', lambda { |e| l(
codalab, rlwrap, 'java', '-Dmodules=core,tables,corenlp', '-cp', 'libsempre/*:lib/*', '-ea', 'edu.stanford.nlp.sempre.Main',
o('executor', 'tables.lambdadcs.LambdaDCSExecutor'),
o('FeatureExtractor.featureDomains', 'denotation lexAlign joinPos skipPos'.split),
o('LanguageAnalyzer.languageAnalyzer', 'corenlp.CoreNLPAnalyzer'),
o('Main.interactive'),
nil) })
addMode('simple-freebase', 'Simple shell for using Freebase', lambda { |e| l(
rlwrap, 'java', '-Dmodules=core,freebase', '-cp', 'libsempre/*:lib/*', '-ea', 'edu.stanford.nlp.sempre.Main',
o('executor', 'freebase.SparqlExecutor'),

View File

@ -195,6 +195,21 @@ public class Example {
LogInfo.end_track();
}
public void logWithoutContext() {
LogInfo.begin_track("Example: %s", utterance);
LogInfo.logs("Tokens: %s", getTokens());
LogInfo.logs("Lemmatized tokens: %s", getLemmaTokens());
LogInfo.logs("POS tags: %s", languageInfo.posTags);
LogInfo.logs("NER tags: %s", languageInfo.nerTags);
LogInfo.logs("NER values: %s", languageInfo.nerValues);
if (targetFormula != null)
LogInfo.logs("targetFormula: %s", targetFormula);
if (targetValue != null)
LogInfo.logs("targetValue: %s", targetValue);
LogInfo.logs("Dependency children: %s", languageInfo.dependencyChildren);
LogInfo.end_track();
}
public List<Derivation> getCorrectDerivations() {
List<Derivation> res = new ArrayList<>();
for (Derivation deriv : predDerivations) {

View File

@ -229,7 +229,7 @@ public class Master {
builder.parser.parse(builder.params, ex, false);
response.ex = ex;
ex.log();
ex.logWithoutContext();
if (ex.predDerivations.size() > 0) {
response.candidateIndex = 0;
printDerivation(response.getDerivation());
@ -377,7 +377,14 @@ public class Master {
} else {
session.context = new ContextValue(tree);
}
} else {
} else if (command.equals("loadgraph")) {
if (tree.children.size() != 2 || !tree.child(1).isLeaf())
throw new RuntimeException("Invalid argument: argument should be a file path");
KnowledgeGraph graph = NaiveKnowledgeGraph.fromFile(tree.child(1).value);
session.context = new ContextValue(session.context.user, session.context.date,
session.context.exchanges, graph);
}
else {
LogInfo.log("Invalid command: " + tree);
}
}

View File

@ -184,6 +184,10 @@ public class NaiveKnowledgeGraph extends KnowledgeGraph {
return new NaiveKnowledgeGraph(triples);
}
public static KnowledgeGraph fromFile(String path) {
return fromLispTree(LispTree.proto.parseFromFile(path).next());
}
@Override
public LispTree toLispTree() {
LispTree tree = LispTree.proto.newList();