rename, README, refactor master

This commit is contained in:
Sida Wang 2017-03-28 10:13:05 -07:00
parent 165160461b
commit 2a5365ef69
29 changed files with 47 additions and 36 deletions

View File

@ -106,7 +106,7 @@ similar your system is.
./run @mode=simple
You should be able to type the following into the shell and get the answer `(number 7)`:
(execute (call + (number 3) (number 4)))
To go further, check out the [tutorial](TUTORIAL.md) and then the [full
@ -133,7 +133,7 @@ For Ubuntu, follow this:
make install
cd ..
on OS/X you can install virtuoso using homebrew by following the instructions
on OS/X you can install virtuoso using homebrew by following the instructions
[here](http://carsten.io/virtuoso-os-on-mac-os/)
To have SEMPRE interact with Virtuoso, the required modules need to be compiled as follow:
@ -166,3 +166,7 @@ Changes from SEMPRE 2.0 to SEMPRE 2.1:
- Added the `tables` package for the paper *Compositional semantic parsing on semi-structured tables* (ACL 2015).
- Add and `overnight` package for the paper *Building a semantic parser overnight* (ACL 2015).
Changes from SEMPRE 2.1 to SEMPRE 2.2:
- Added the `interactive` package for the paper *Naturalizing a programming language through interaction* (ACL 2017).

View File

@ -7,6 +7,7 @@
$: << 'fig/lib'
require 'execrunner'
$path = 'interactive'
$modes = []
def addMode(name, description, func)
@ -94,18 +95,18 @@ addMode('test', 'Run unit tests for interactive stuff', lambda { |e|
if e[:class]
l('-testclass', 'edu.stanford.nlp.sempre.interactive.test.' + e[:class])
else
'shrdlurn/testng.xml'
"./#{$path}/testng.xml"
end
},
nil)
})
addMode('community-dep', 'dependencies for the community server', lambda { |e| l(
l('python ./shrdlurn/community-server/install-deps.py'),
l('python ./#{$path}/community-server/install-deps.py'),
nil)})
addMode('community', 'start the community server', lambda { |e| l(
l('python ./shrdlurn/community-server/server.py -- port 8403'),
l('python ./#{$path}/community-server/server.py -- port 8403'),
nil)})
addMode('simulator', 'run the simulator', lambda { |e| l(
@ -130,16 +131,16 @@ addMode('simulator', 'run the simulator', lambda { |e| l(
}),
letDefault(:task, 'sidaw'),
sel(:task, {
'freebig' => o('logFiles', './shrdlurn/queries/freebuildbig-0206.json.gz'),
'freebigdef' => o('logFiles', './shrdlurn/queries/freebuildbig-0206.def.json.gz'),
'freebigcontext' => o('logFiles', './shrdlurn/queries/freebuildbig-0206.context.json.gz'),
'freebig' => o('logFiles', "./#{$path}/queries/freebuildbig-0206.json.gz"),
'freebigdef' => o('logFiles', "./#{$path}/queries/freebuildbig-0206.def.json.gz"),
'freebigcontext' => o('logFiles', "./#{$path}/queries/freebuildbig-0206.context.json.gz"),
'qual1' => o('logFiles', './shrdlurn/queries/qualifier1-0118.json.gz'),
'qual2' => o('logFiles', './shrdlurn/queries/qualifier2-0129.json.gz'),
'qual3' => o('logFiles', './shrdlurn/queries/qualifier3-0201.json.gz'), # both 2 and 3
'free1' => o('logFiles', './shrdlurn/queries/freebuild1-0121.json.gz'),
'free2' => o('logFiles', './shrdlurn/queries/freebuild2-0127.json.gz'),
'sidaw' => o('logFiles', './shrdlurn/queries/sidaw.json'),
'qual1' => o('logFiles', "./#{$path}/queries/qualifier1-0118.json.gz"),
'qual2' => o('logFiles', "./#{$path}/queries/qualifier2-0129.json.gz"),
'qual3' => o('logFiles', "./#{$path}/queries/qualifier3-0201.json.gz"), # both 2 and 3
'free1' => o('logFiles', "./#{$path}/queries/freebuild1-0121.json.gz"),
'free2' => o('logFiles', "./#{$path}/queries/freebuild2-0127.json.gz"),
'sidaw' => o('logFiles', "./#{$path}/queries/sidaw.json"),
}),
nil)})
@ -159,7 +160,7 @@ addMode('voxelurn', 'interactive semantic parsing in a VoxelWorld', lambda { |e|
o('DALExecutor.printStackTrace', true),
o('VoxelWorld.maxBlocks', 100000),
selo(0, 'DALExecutor.worldType', 'VoxelWorld', 'CalendarWorld', 'Otherworld'),
selo(0, 'Grammar.inPaths', './shrdlurn/voxelurn.grammar', './shrdlurn/calendar.grammar'),
selo(0, 'Grammar.inPaths', "./#{$path}/voxelurn.grammar"),
o('Params.initWeightsRandomly', false),
o('Grammar.binarizeRules', false),
@ -213,7 +214,7 @@ addMode('voxelurn', 'interactive semantic parsing in a VoxelWorld', lambda { |e|
o('Derivation.showRules', false),
o('NumberFn.allowedRange', 0, 100),
o('SimpleLexicon.inPaths', 'shrdlurn/csscolors.lexicon'),
o('SimpleLexicon.inPaths', "./#{$path}/csscolors.lexicon"),
# o('Grammar.tags', 'morecolors'),
# o('Grammar.tags', 'morenumbers', 'morecolors'),

View File

@ -1,6 +1,6 @@
# domain specific grammar for voxelurn
(include DAL.grammar)
(include dal.grammar)
# domain specific actions:
(def @put put)

View File

@ -47,7 +47,7 @@ public class Derivation implements SemanticFn.Callable, HasScore {
/**
* Information for grammar induction.
* For each descendant derivation of the body, this class tracks where in the head it matches
* For each descendant derivation of the body, this class tracks where and what in the head it matches
* GrammarInfo.start, GrammarInfo.end refer to matching positions in the head, as opposed to the body
* @author sidaw
**/
@ -81,8 +81,8 @@ public class Derivation implements SemanticFn.Callable, HasScore {
// Information for scoring
private final FeatureVector localFeatureVector; // Features
public double score = Double.NaN; // Weighted combination of features
public double prob = Double.NaN; // Probability (normalized exp of score).
double score = Double.NaN; // Weighted combination of features
double prob = Double.NaN; // Probability (normalized exp of score).
// Used during parsing (by FeatureExtractor, SemanticFn) to cache arbitrary
// computation across different sub-Derivations.

View File

@ -2,6 +2,7 @@ package edu.stanford.nlp.sempre;
import java.lang.reflect.Constructor;
import fig.basic.Option;
import fig.exec.Execution;
@ -26,20 +27,25 @@ public class Main implements Runnable {
learner.learn();
if (server || interactive) {
try {
Class<?> masterClass = Class.forName(masterType);
Constructor<?> constructor = masterClass.getConstructor(Builder.class);
Master master = (Master)constructor.newInstance(builder);
if (server)
master.runServer();
else if (interactive)
master.runInteractivePrompt();
} catch (Throwable t) {
t.printStackTrace();
}
Master master = createMaster(masterType, builder);
if (server)
master.runServer();
else if (interactive)
master.runInteractivePrompt();
}
}
public Master createMaster(String masterType, Builder builder) {
try {
Class<?> masterClass = Class.forName(masterType);
Constructor<?> constructor = masterClass.getConstructor(Builder.class);
return (Master)constructor.newInstance(builder);
} catch (Throwable t) {
t.printStackTrace();
}
return null;
}
public static void main(String[] args) {
Execution.run(args, "Main", new Main(), Master.getOptionsParser());
}

View File

@ -194,8 +194,8 @@ public class InteractiveServer {
item.put("value", value.sortString());
else
item.put("value", "[[]]");
item.put("score", deriv.score);
item.put("prob", deriv.prob);
item.put("score", deriv.getScore());
item.put("prob", deriv.getProb());
item.put("anchored", deriv.allAnchored); // used only anchored rules
item.put("formula", deriv.formula.toLispTree().toString());
items.add(item);

View File

@ -92,7 +92,7 @@ public class Simulator implements Runnable {
@Option
public static String reqParams = "grammar=0&cite=0&learn=0";
@Option
public static List<String> logFiles = Lists.newArrayList("./shrdlurn/commandInputs/sidaw.json.log");
public static List<String> logFiles = null;
public void readQueries() {
// T.printAllRules();

View File

@ -54,7 +54,7 @@ public class FloatingParsingTest {
DALExecutor.opts.convertNumberValues = true;
DALExecutor.opts.printStackTrace = true;
DALExecutor.opts.worldType = "VoxelWorld";
Grammar.opts.inPaths = Lists.newArrayList("./shrdlurn/voxelurn.grammar");
Grammar.opts.inPaths = Lists.newArrayList("./interactive/voxelurn.grammar");
Grammar.opts.useApplyFn = "interactive.ApplyFn";
Grammar.opts.binarizeRules = false;

View File

@ -54,7 +54,7 @@ public class GrammarInducerTest {
Derivation.opts.showCat = true;
LanguageAnalyzer.opts.languageAnalyzer = "interactive.DALAnalyzer";
Grammar.opts.inPaths = Lists.newArrayList("./shrdlurn/voxelurn.grammar");
Grammar.opts.inPaths = Lists.newArrayList("./interactive/voxelurn.grammar");
Grammar.opts.useApplyFn = "interactive.ApplyFn";
Grammar.opts.binarizeRules = false;