]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Text/Parsers/Isidore.hs
[TEXT][PARSERS] Isidore update query.
[gargantext.git] / src / Gargantext / Text / Parsers / Isidore.hs
1 {-# LANGUAGE NoImplicitPrelude #-}
2 {-# LANGUAGE ScopedTypeVariables #-}
3 {-# LANGUAGE OverloadedStrings #-}
4
5 module Gargantext.Text.Parsers.Isidore where
6
7 import Gargantext.Prelude
8 import Database.HSparql.Connection
9 import Database.HSparql.QueryGenerator
10
11 -- import Data.RDF hiding (triple)
12 import Data.Text hiding (groupBy)
13
14 route = "http://isidore.science/sparql/"
15
16
17 --selectExample :: IO (Maybe [Text])
18 isidore q = do
19 res <- selectQuery route $ simpleSelect q
20 pure res
21
22 simpleSelect :: Text -> Query SelectQuery
23 simpleSelect q = do
24 isidore <- prefix "isidore" (iriRef "http://www.rechercheisidore.fr/class")
25 rdf <- prefix "rdf" (iriRef "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
26 dcterms <- prefix "dcterms" (iriRef "http://purl.org/dc/terms")
27 dc <- prefix "dc" (iriRef "http://purl.org/dc")
28
29 doc <- var
30 title <- var
31 date <- var
32 abstract <- var
33 source <- var
34
35 triple doc (rdf .:. "type") (isidore .:. "BibliographicalResource")
36 triple doc (dcterms .:. "title") title
37 triple doc (dcterms .:. "date") date
38 triple doc (dcterms .:. "source") source
39 triple doc (dc .:. "description") abstract
40
41 filterExpr $ (.||.) (contains title q) (contains abstract q)
42 groupBy title
43 groupBy source
44
45 selectVars [title, date, source, abstract]