From 1d851bbd22a8c47568dfc9af1c6f38b8dea9e36a Mon Sep 17 00:00:00 2001 From: sroy9 Date: Thu, 1 Jun 2017 21:10:45 -0500 Subject: [PATCH] better script and relevance --- data/handcrafted/questions.json | 63 ++++++++++-------------------- runAllExpts2.sh | 5 ++- src/main/java/logic/Relevance.java | 15 +++---- src/main/java/reader/Dataset.java | 47 +++++++++++++++++++--- 4 files changed, 75 insertions(+), 55 deletions(-) diff --git a/data/handcrafted/questions.json b/data/handcrafted/questions.json index ef6a4e3..8028e2f 100644 --- a/data/handcrafted/questions.json +++ b/data/handcrafted/questions.json @@ -12,8 +12,7 @@ "lSolutions": [ 43.0 ], - "infType": 0, - "key": "0_0" + "rates": [] }, { "iIndex": 100002, @@ -28,8 +27,7 @@ "lSolutions": [ 97.0 ], - "infType": 0, - "key": "0_1" + "rates": [] }, { "iIndex": 100003, @@ -44,8 +42,7 @@ "lSolutions": [ 43.0 ], - "infType": 0, - "key": "0_1" + "rates": [] }, { "iIndex": 100004, @@ -60,8 +57,7 @@ "lSolutions": [ 43.0 ], - "infType": 0, - "key": "1_0" + "rates": [] }, { "iIndex": 100005, @@ -76,8 +72,7 @@ "lSolutions": [ 97.0 ], - "infType": 0, - "key": "1_0" + "rates": [] }, { "iIndex": 100006, @@ -92,8 +87,7 @@ "lSolutions": [ 43.0 ], - "infType": 0, - "key": "0_1" + "rates": [] }, { "iIndex": 100007, @@ -108,8 +102,7 @@ "lSolutions": [ 97.0 ], - "infType": 0, - "key": "0_1" + "rates": [] }, { "iIndex": 100008, @@ -124,8 +117,7 @@ "lSolutions": [ 97.0 ], - "infType": 0, - "key": "1_0" + "rates": [] }, { "iIndex": 100009, @@ -140,8 +132,7 @@ "lSolutions": [ 43.0 ], - "infType": 0, - "key": "1_0" + "rates": [] }, { "iIndex": 100010, @@ -156,8 +147,7 @@ "lSolutions": [ 5 ], - "infType": 2, - "key": "0_0" + "rates": [] }, { "iIndex": 100011, @@ -172,8 +162,7 @@ "lSolutions": [ 11 ], - "infType": 2, - "key": "0_1" + "rates": [] }, { "iIndex": 100012, @@ -188,8 +177,7 @@ "lSolutions": [ 5 ], - "infType": 2, - "key": "0_0" + "rates": [] }, { "iIndex": 100013, @@ -204,8 +192,7 @@ "lSolutions": [ 11 ], - "infType": 2, - "key": "0_1" + "rates": [] }, { "iIndex": 100014, @@ -220,8 +207,7 @@ "lSolutions": [ 1 ], - "infType": 2, - "key": "1" + "rates": [] }, { "iIndex": 100015, @@ -236,8 +222,7 @@ "lSolutions": [ 20 ], - "infType": 3, - "key": "1_DEN" + "rates": [1] }, { "iIndex": 100016, @@ -252,8 +237,7 @@ "lSolutions": [ 4 ], - "infType": 3, - "key": "0_NUM" + "rates": [1] }, { "iIndex": 100017, @@ -268,8 +252,7 @@ "lSolutions": [ 4 ], - "infType": 3, - "key": "QUES" + "rates": [-1] }, { "iIndex": 100018, @@ -284,8 +267,7 @@ "lSolutions": [ 4 ], - "infType": 3, - "key": "QUES" + "rates": [-1] }, { "iIndex": 100019, @@ -300,8 +282,7 @@ "lSolutions": [ 11 ], - "infType": 2, - "key": "SIBLING" + "rates": [] }, { "iIndex": 100020, @@ -316,8 +297,7 @@ "lSolutions": [ 5 ], - "infType": 2, - "key": "HYPER" + "rates": [] }, { "iIndex": 100021, @@ -332,8 +312,7 @@ "lSolutions": [ 5 ], - "infType": 2, - "key": "HYPO" + "rates": [] } ] diff --git a/runAllExpts2.sh b/runAllExpts2.sh index a8e7e13..6754dd5 100644 --- a/runAllExpts2.sh +++ b/runAllExpts2.sh @@ -6,6 +6,8 @@ sh run.sh --mode UnitDep --cv data/allArithLex/fold0.txt data/allArithLex/fold1. sh run.sh --mode UnitDep --cv data/allArithTmpl/fold0.txt data/allArithTmpl/fold1.txt data/allArithTmpl/fold2.txt data/allArithTmpl/fold3.txt data/allArithTmpl/fold4.txt --model_dir models2/ --print_mistakes > log/UnitDepAllTmpl.out +sh run.sh --mode UnitDep --train data/perturb/old.txt --test data/perturb/new.txt --model_dir models2/ --print_mistakes > log/UnitDepPerturb.out + sh run.sh --mode LCA --cv data/allArith/fold0.txt data/allArith/fold1.txt data/allArith/fold2.txt data/allArith/fold3.txt data/allArith/fold4.txt --model_dir models2/ --print_mistakes > log/LCAAll.out @@ -14,6 +16,7 @@ sh run.sh --mode LCA --cv data/allArithLex/fold0.txt data/allArithLex/fold1.txt sh run.sh --mode LCA --cv data/allArithTmpl/fold0.txt data/allArithTmpl/fold1.txt data/allArithTmpl/fold2.txt data/allArithTmpl/fold3.txt data/allArithTmpl/fold4.txt --model_dir models2/ --print_mistakes > log/LCAAllTmpl.out +sh run.sh --mode LCA --train data/perturb/old.txt --test data/perturb/new.txt --model_dir models2/ --print_mistakes > log/LCAPerturb.out @@ -23,4 +26,4 @@ sh run.sh --mode E2ELogic --cv data/allArithLex/fold0.txt data/allArithLex/fold1 sh run.sh --mode E2ELogic --cv data/allArithTmpl/fold0.txt data/allArithTmpl/fold1.txt data/allArithTmpl/fold2.txt data/allArithTmpl/fold3.txt data/allArithTmpl/fold4.txt --model_dir models2/ --print_mistakes > log/E2ELogicAllTmpl.out - +sh run.sh --mode E2ELogic --train data/perturb/old.txt --test data/perturb/new.txt --model_dir models2/ --print_mistakes > log/E2ELogicPerturb.out diff --git a/src/main/java/logic/Relevance.java b/src/main/java/logic/Relevance.java index 1f6edd6..e08eebe 100644 --- a/src/main/java/logic/Relevance.java +++ b/src/main/java/logic/Relevance.java @@ -165,8 +165,9 @@ public static boolean irrelevance(LogicX x, int quantIndex) { double maxSim = 0.0, minSim = 1.0, maxSimForIndex = 0.0; for(int i=0; i maxSimForIndex) maxSimForIndex = sim; } else { @@ -179,11 +180,11 @@ public static boolean irrelevance(LogicX x, int quantIndex) { } } } - System.out.println("ProblemId: "+x.problemId+"|| QuantIndex: "+quantIndex+ - "|| MaxSimForIndex: "+maxSimForIndex+"|| MaxSim: "+maxSim+ - "|| MinSim: "+minSim); - System.out.println("Extractions: "+Arrays.asList(unitRates)); - System.out.println(); +// System.out.println("ProblemId: "+x.problemId+"|| QuantIndex: "+quantIndex+ +// "|| MaxSimForIndex: "+maxSimForIndex+"|| MaxSim: "+maxSim+ +// "|| MinSim: "+minSim); +// System.out.println("Extractions: "+Arrays.asList(unitRates)); +// System.out.println(); if(minSim - maxSimForIndex > 0.51 && !otherDependentNumber) { if(Tools.jaccardSim(quesUnit, unitRates.get( new IntPair(quantIndex, 0))) < minSim-0.01) { diff --git a/src/main/java/reader/Dataset.java b/src/main/java/reader/Dataset.java index 6239f71..d11822f 100644 --- a/src/main/java/reader/Dataset.java +++ b/src/main/java/reader/Dataset.java @@ -243,6 +243,7 @@ public static void combineTwoSetsToOneDataset() throws Exception { } public static void consistencyChecks() throws Exception { + System.out.println("Running consistency checks"); String json = FileUtils.readFileToString(new File("data/questions.json")); List kushmanProbs = new Gson().fromJson(json, new TypeToken>(){}.getType()); @@ -403,7 +404,11 @@ public static void analyzeErrors(String fileName1, String fileName2, int total) Set bothWrong = new HashSet<>(); Set RightWrong = new HashSet<>(); Set WrongRight = new HashSet<>(); - for(String line : lines1) { + Map probIdToString1 = new HashMap<>(); + Map probIdToString2 = new HashMap<>(); + String bW = "", RW = "", WR = ""; + for(int j=0; j