Commit 9d8bf9cf authored by Georgi Angelov's avatar Georgi Angelov
Browse files

Added similar return function for solveWithAnswer and added a solveWithAnswer...

Added similar return function for solveWithAnswer and added a solveWithAnswer endpoint which takes /solveWithAnswer/<clue string>/<answer length>/<predicted answer>
parent 2167912e
......@@ -14,5 +14,8 @@ myConf = Conf
clue = ("Peeling paint, profit slack, upset, in a state",10)
main = simpleHTTP myConf $ msum [ dir "solve" $ path $ \s -> path $ \n -> ok $ show (solveReturn (s,n))
main = simpleHTTP myConf $ msum [ dir "solve" $ path $ \clue -> path $ \wordLength
-> ok $ show (solveReturn (clue, wordLength))
, dir "solveWithAnswer" $ path $ \clue -> path $ \wordLength -> path $ \answer
-> ok $ show (solveWithAnswerReturn (clue, wordLength) answer)
]
......@@ -43,6 +43,7 @@ head' sols
solve clue
= showSolutions False clue "" id head' False
-- Returns list of answers
solveReturn clue
= returnSolutions False clue "" id head' False
......@@ -55,9 +56,13 @@ solveAllFull clue
solveWithCache clue
= showSolutions False clue "" id head' True
--Returns list with the answer if solved
solveWithAnswer clue answer
= showSolutions False clue answer id head' False
solveWithAnswerReturn clue answer
= returnSolutions False clue answer id head' False
solveOne n clue
= showSolutions True clue "" (\ps -> [ps !! n]) head' False
......@@ -97,6 +102,7 @@ showSolutions displayFull clue answer prefilter postProcess evalCacheOn
sols' = postProcess sols
-- Same as above function but returns a list of solutions instead
returnSolutions displayFull clue answer prefilter postProcess evalCacheOn = extractSols
where
acceptAnyDef = not (null answer)
......@@ -111,19 +117,6 @@ returnSolutions displayFull clue answer prefilter postProcess evalCacheOn = extr
extractSol (_,_,_, R (sol, _)) = sol
-- returnSolutions displayFull clue answer prefilter postProcess evalCacheOn
-- | null sols' = "The clue is: " ++ show clue ++ "\nSorry, but I couldn't solve it\n"
-- | otherwise = foldr appendSolutions "" sols'
-- where
-- appendSolutions sol1 sol2 = show sol1 ++ "," ++ sol2
--
-- acceptAnyDef = not (null answer)
-- (parses, pCache) = if null answer
-- then prunedParses clue
-- else prunedParsesWithAnswer clue answer
-- parses' = prefilter parses
-- sols = evaluate parses' pCache clue answer evalCacheOn
-- sols' = postProcess sols
dumpIndicators :: (IndicatorPredicateSet, String, [String]) -> IO ()
dumpIndicators (inds, textString, stemmedTextWords)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment