bug fix for more numbers and colors

This commit is contained in:
Sida Wang 2017-04-04 18:13:22 -07:00
parent d4621b8d53
commit a9ab6c8f7a
10 changed files with 48 additions and 34 deletions

View File

@ -16,12 +16,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 39,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"887\n",
"log.file\tstate/execs/887.exec/log\n",
"Simulator.reqParams\tgrammar=1&cite=1&learn=1&logging=0\n",
"Simulator.logFiles\t./interactive/queries/freebuildbig-0206.def.json.gz\n",
"500 lines in plotInfo\n",
"[]\n",
"errors:20, stats.uncaught_error:0\n",
"{'total_rules': 608, 'total_failed': 151, 'total_def_queries': 480, 'total_body': 1812}\n",
"failpercent: 0.0833\n"
]
}
],
"source": [
"import csv\n",
"import numpy as np\n",
@ -79,6 +95,15 @@
"\n",
"print_stats()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {

View File

@ -106,7 +106,7 @@ l('python ./#{$path}/community-server/install-deps.py'),
nil)})
addMode('community', 'start the community server', lambda { |e| l(
l('python ./#{$path}/community-server/server.py -- port 8403'),
l("python ./#{$path}/community-server/server.py -- port 8403"),
nil)})
addMode('simulator', 'run the simulator', lambda { |e| l(
@ -171,10 +171,10 @@ addMode('voxelurn', 'interactive semantic parsing in a VoxelWorld', lambda { |e|
o('Parser.pruneErrorValues', true),
o('Parser', 'interactive.BeamFloatingParser'),
o('Parser.callSetEvaluation', false),
o('Parser.coarsePrune', 'false'),
o('Parser.coarsePrune', 'true'),
o('Parser.beamSize', 50),
o('BeamFloatingParser.maxNewTreesPerSpan', 10000),
o('BeamFloatingParser.maxNewTreesPerSpan', 5001),
o('ParserState.customExpectedCounts', 'None'),
selo(0, 'BeamFloatingParser.floatStrategy', 'Never', 'NoParse', 'Always'),
@ -216,8 +216,8 @@ addMode('voxelurn', 'interactive semantic parsing in a VoxelWorld', lambda { |e|
o('NumberFn.allowedRange', 0, 100),
o('SimpleLexicon.inPaths', "./#{$path}/csscolors.lexicon"),
# o('Grammar.tags', 'morecolors'),
# o('Grammar.tags', 'morenumbers', 'morecolors'),
#o('Grammar.tags', 'morenumbers', 'morecolors'),
o('Grammar.tags', 'morecolors', 'morenumbers'),
lambda { |e| system 'mkdir -p ./int-output/'; nil},
lambda { |e| system 'mkdir -p ./int-output/log/'; nil},

View File

@ -56,7 +56,7 @@
(rule $Number ($TOKEN) (NumberFn) (anchored 1)))
(when morecolors
(rule $Color ($TOKEN) (SimpleLexiconFn (type color)) (anchored 1)))
(rule $Color ($TOKEN) (SimpleLexiconFn) (anchored 1)))
(when (not morenumbers)
(for @num (0 1 2 3 4 5 6 7 8 9 10)

View File

@ -541,7 +541,7 @@ public class Derivation implements SemanticFn.Callable, HasScore {
}
public boolean allAnchored() {
if (rule.isFloating() || rule.isInduced() || !this.allAnchored) {
if (rule.isInduced() || !this.allAnchored) {
this.allAnchored = false;
return false;
} else {

View File

@ -1,8 +1,9 @@
package edu.stanford.nlp.sempre;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
/**
@ -11,7 +12,7 @@ import java.util.Set;
*/
public class Trie {
public ArrayList<Rule> rules = new ArrayList<>();
HashMap<String, Trie> children = new HashMap<>();
Map<String, Trie> children = new LinkedHashMap<>();
// Set of LHS categories of all rules in this subtree
public Set<String> cats = new HashSet<>();

View File

@ -25,7 +25,6 @@ public class DALAnalyzer extends LanguageAnalyzer {
private static final String[] numbers = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight",
"nine", "ten" };
private static final String[] determiners = { "the", "a", "an", "that" };
@Override
public LanguageInfo analyze(String utterance) {

View File

@ -13,27 +13,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.ObjectArrays;
import com.google.common.collect.Sets;
import edu.stanford.nlp.sempre.ActionFormula;
import edu.stanford.nlp.sempre.AggregateFormula;
import edu.stanford.nlp.sempre.ArithmeticFormula;
import edu.stanford.nlp.sempre.BooleanValue;
import edu.stanford.nlp.sempre.CallFormula;
import edu.stanford.nlp.sempre.ContextValue;
import edu.stanford.nlp.sempre.ErrorValue;
import edu.stanford.nlp.sempre.Executor;
import edu.stanford.nlp.sempre.Formula;
import edu.stanford.nlp.sempre.Formulas;
import edu.stanford.nlp.sempre.JoinFormula;
import edu.stanford.nlp.sempre.ListValue;
import edu.stanford.nlp.sempre.MergeFormula;
import edu.stanford.nlp.sempre.NameValue;
import edu.stanford.nlp.sempre.NotFormula;
import edu.stanford.nlp.sempre.NumberValue;
import edu.stanford.nlp.sempre.ReverseFormula;
import edu.stanford.nlp.sempre.StringValue;
import edu.stanford.nlp.sempre.SuperlativeFormula;
import edu.stanford.nlp.sempre.Value;
import edu.stanford.nlp.sempre.ValueFormula;
import edu.stanford.nlp.sempre.*;
import fig.basic.LogInfo;
import fig.basic.Option;

View File

@ -111,7 +111,7 @@ public class GrammarInducer {
LogInfo.logs("Simple Packing", chartList.size());
LogInfo.logs("chartList.size = %d", chartList.size());
LogInfo.log("Potential packings: ");
this.matches.forEach(d -> LogInfo.logs("%f: %s\t", d.getScore(), d.formula));
this.matches.forEach(d -> LogInfo.logs("%f: %s\t %s", d.getScore(), d.formula, d.allAnchored()));
LogInfo.logs("packing: %s", packing);
LogInfo.logs("formulaToCat: %s", formulaToCat);
}

View File

@ -276,7 +276,12 @@ public class InteractiveMaster extends Master {
throw BadInteractionException.headIsEmpty(head);
if (isNonsense(exHead))
throw BadInteractionException.nonSenseDefinition(head);
boolean coarsePrune = Parser.opts.coarsePrune;
Parser.opts.coarsePrune = false;
BeamFloatingParserState state = (BeamFloatingParserState) parser.parse(params, exHead, true);
Parser.opts.coarsePrune = coarsePrune;
if (GrammarInducer.getParseStatus(exHead) == GrammarInducer.ParseStatus.Core)
throw BadInteractionException.headIsCore(head);

View File

@ -90,6 +90,8 @@ public class Simulator implements Runnable {
@Option
public static boolean useThreads = false;
@Option
public static long maxQueries = Long.MAX_VALUE;
@Option
public static String reqParams = "grammar=0&cite=0&learn=0";
@Option
public static List<String> logFiles = null;
@ -117,6 +119,8 @@ public class Simulator implements Runnable {
for (String l : lines) {
numLinesRead++;
if (numLinesRead > maxQueries)
break;
LogInfo.logs("Line %d", numLinesRead);
if (!useThreads) {
executeLine(l);