Skip to content

Commit f74bbbd

Browse files
committed
added -no-ranking option for situations where ranking is not needed
1 parent 0a219c7 commit f74bbbd

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ parallel:
101101
cat test/exx.dk >>tmp/parallel.dk
102102
cat test/sets.dk >>tmp/parallel.dk
103103
cat test/top100.dk >>tmp/parallel.dk
104-
$(RUN) -parallel-data tmp/parallel.dk >tmp/parallel-informath.jsonl
104+
$(RUN) -parallel-data -variations -no-ranking tmp/parallel.dk >tmp/parallel-informath.jsonl
105105

106106
parallel-def:
107107
tail -150 src/BaseConstants.dk >tmp/parallel.dk
108108
cat test/exx.dk >>tmp/parallel.dk
109109
cat test/sets.dk >>tmp/parallel.dk
110-
$(RUN) -parallel-data -no-unlex -dedukti-tokens tmp/parallel.dk >tmp/parallel-def-train.jsonl
110+
$(RUN) -parallel-data -variations -no-ranking -no-unlex -dedukti-tokens tmp/parallel.dk >tmp/parallel-def-train.jsonl
111111

112112
matita:
113113
$(RUN) test/mini-matita.dk

app/RunInformath.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ helpMsg4 = unlines [
6868
just "-nbest=<int>" "show <int> best NLG results",
6969
just "-to-latex-doc" "print valid LaTeX doc with preamble",
7070
just "-weights=<ints>" "weights of scores, default 1,1,1,1,1,1,1",
71+
just "-no-ranking" "do not rank the NLG results (which can be expensive)",
72+
just "-test-ambiguity" "test ambiguity when ranking NLG results (can be very slow)",
7173
just "-parallel-data" "print complete parallel data in jsonl",
7274
just "-to-lang=<lang>" "linearize to natural language <lang>",
7375
just "-to-formalism=<formalism>" "convert to <formalism> instead of natural language",
@@ -77,7 +79,6 @@ helpMsg4 = unlines [
7779
just "-from-lang=<lang>" "parse from <lang>",
7880
just "-translate" "translate text without parsing parts in $...$",
7981
just "-unknown-words" "show idents in text file not in grammar",
80-
just "-test-ambiguity" "test ambiguity when ranking NLG results",
8182
"",
8283
"* General output options:",
8384
"",

src/Ranking.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ data Scores = Scores {
1818
extra_parses :: Int
1919
} deriving Show
2020

21+
-- for cases where (possibly expensive) scoring is not needed
22+
noScores :: Scores
23+
noScores = Scores 0 0 0 0 0 0 0
24+
2125
scoreString :: Env -> String -> Scores
2226
scoreString env s = Scores {
2327
tree_length = 0, -- computed separately
@@ -71,6 +75,9 @@ scoreTreeAndString env (t, s) =
7175

7276
-- sorts trees from lowest to highest total score
7377
rankTreesAndStrings :: Env -> [(Expr, String)] -> [((Expr, String), (Scores, Int))]
74-
rankTreesAndStrings env tss = sortOn (snd . snd) [(ts, scoreTreeAndString env ts) | ts <- tss]
78+
rankTreesAndStrings env tss =
79+
if isFlag "-no-ranking" env
80+
then [(ts, (noScores, 0)) | ts <- tss]
81+
else sortOn (snd . snd) [(ts, scoreTreeAndString env ts) | ts <- tss]
7582

7683

0 commit comments

Comments
 (0)