Commit 357bb9a1 authored by Alexandre Delanoë's avatar Alexandre Delanoë

tests

parent 3c80b872
......@@ -22,6 +22,11 @@ import qualified Network.Api.Arxiv as Ax
------------------------------------------------------------
type Limit = Int
type Soup = Tag String
------------------------------------------------------------
-- apiTotal_simple :: [String] -> IO Int
------------------------------------------------------------
-- | Simple Query search for terms in All fields
......@@ -45,10 +50,9 @@ complexQuery =
in Ax.Query { Ax.qExp = Just $ Exp $ All ["nuclear fusion", "plasma"]
, Ax.qIds = []
, Ax.qStart = 0
, Ax.qItems = 25
, Ax.qItems = 50
}
type Soup = Tag String
execQuery :: Maybe Limit -> Ax.Query -> IO [Result]
execQuery Nothing q = C.runConduitRes (searchAxv q .| CL.consume)
......@@ -102,6 +106,7 @@ data Result = Result { doi :: String
, year :: String
, title :: String
, abstract :: String
, total :: Int
} deriving (Show)
mkResult :: [Soup] -> Result
......@@ -115,11 +120,13 @@ mkResult sp = let doi' = Ax.getDoi sp
year' = Ax.getYear sp
title' = Ax.getTitle sp & clean'
abstract' = Ax.getSummary sp & clean'
total' = Ax.totalResults sp
in ( Result doi' url'
primaryCategory' categories'
journal' authors'
publication_date' year'
title' abstract'
total'
)
where clean' x = let x' = clean ['\n', '\r', '\t'] x
in if null x' then "Not found" else x'
......
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