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

tests

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