Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Przemyslaw Kaminski
hal
Commits
240a13e7
Verified
Commit
240a13e7
authored
Jul 25, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement search with given language (for abstracts etc)
parent
0d82e5a6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
22 deletions
+47
-22
crawlerHAL.cabal
crawlerHAL.cabal
+1
-0
HAL.hs
src/HAL.hs
+2
-1
Corpus.hs
src/HAL/Doc/Corpus.hs
+30
-18
Utils.hs
src/HAL/Utils.hs
+11
-0
Tree.hs
src/Tree.hs
+3
-3
No files found.
crawlerHAL.cabal
View file @
240a13e7
...
...
@@ -32,6 +32,7 @@ library
HAL.Doc.Corpus
HAL.Doc.EntityTree
HAL.Doc.Struct
HAL.Utils
Tree
other-modules:
Paths_crawlerHAL
...
...
src/HAL.hs
View file @
240a13e7
...
...
@@ -7,6 +7,7 @@ import Data.Text
import
HAL.Client
import
HAL.Doc.Corpus
import
HAL.Doc.Struct
import
HAL.Utils
(
langAbstractS
)
import
Network.HTTP.Client
(
newManager
)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Protolude
...
...
@@ -72,7 +73,7 @@ countResults q = do
requestedFields
::
Maybe
ISO639_1
->
Text
requestedFields
(
Just
EN
)
=
"docid,title_s,en_abstract_s,submittedDate_s,source_s,authFullName_s,authOrganism_s"
requestedFields
(
Just
FR
)
=
"docid,title_s,en_abstract_s,fr_abstract_s
,submittedDate_s,source_s,authFullName_s,authOrganism_s"
requestedFields
(
Just
lang
)
=
"docid,title_s,en_abstract_s,"
<>
langAbstractS
lang
<>
"
,submittedDate_s,source_s,authFullName_s,authOrganism_s"
requestedFields
_
=
requestedFields
(
Just
EN
)
structFields
::
Text
...
...
src/HAL/Doc/Corpus.hs
View file @
240a13e7
...
...
@@ -4,8 +4,12 @@ module HAL.Doc.Corpus where
import
Control.Lens
qualified
as
L
import
Data.Aeson
import
Data.Aeson.Key
(
fromText
)
import
Data.Default
import
Data.Map.Strict
qualified
as
Map
import
GHC.Generics
import
HAL.Utils
(
allLangs
,
langAbstractS
)
import
Data.LanguageCodes
(
ISO639_1
(
..
))
import
Protolude
import
Servant.API
(
ToHttpApiData
(
..
))
...
...
@@ -13,6 +17,7 @@ data Corpus = Corpus
{
_corpus_docid
::
Text
,
_corpus_title
::
[
Text
]
,
_corpus_abstract
::
[
Text
]
,
_corpus_abstract_lang_map
::
Map
ISO639_1
[
Text
]
,
_corpus_date
::
Maybe
Text
,
_corpus_source
::
Maybe
Text
,
_corpus_authors_names
::
[
Text
]
...
...
@@ -22,19 +27,26 @@ data Corpus = Corpus
L
.
makeLenses
''
C
orpus
instance
Default
Corpus
where
def
=
Corpus
"default Id"
def
def
def
def
def
def
def
def
=
Corpus
"default Id"
def
def
def
def
def
def
def
def
instance
FromJSON
Corpus
where
parseJSON
=
withObject
"Corpus"
$
\
o
->
Corpus
<$>
(
o
.:
"docid"
)
<*>
(
o
.:
"title_s"
<|>
return
[]
)
<*>
(
o
.:
"en_abstract_s"
<|>
return
[]
)
<*>
(
o
.:?
"submittedDate_s"
)
<*>
(
o
.:?
"source_s"
)
<*>
(
o
.:
"authFullName_s"
<|>
return
[]
)
<*>
(
o
.:
"authOrganism_s"
<|>
return
[]
)
<*>
(
o
.:
"structId_i"
<|>
return
[]
)
parseJSON
=
withObject
"Corpus"
$
\
o
->
do
_corpus_docid
<-
(
o
.:
"docid"
)
_corpus_title
<-
(
o
.:
"title_s"
<|>
return
[]
)
_corpus_abstract
<-
(
o
.:
"en_abstract_s"
<|>
return
[]
)
_corpus_date
<-
(
o
.:?
"submittedDate_s"
)
_corpus_source
<-
(
o
.:?
"source_s"
)
_corpus_authors_names
<-
(
o
.:
"authFullName_s"
<|>
return
[]
)
_corpus_authors_affiliations
<-
(
o
.:
"authOrganism_s"
<|>
return
[]
)
_corpus_struct_id
<-
(
o
.:
"structId_i"
<|>
return
[]
)
abstracts
<-
mapM
(
\
lang
->
do
ma
<-
o
.:?
(
fromText
$
langAbstractS
lang
)
pure
$
(
\
a
->
(
lang
,
a
))
<$>
ma
)
allLangs
let
_corpus_abstract_lang_map
=
Map
.
fromList
$
catMaybes
abstracts
pure
$
Corpus
{
..
}
instance
ToHttpApiData
Corpus
where
toUrlPiece
_
=
"docid,title_s,en_abstract_s,fr_abstract_s,submittedDate_s,source_s,authFullName_s,authOrganism_s,structId_i"
src/HAL/Utils.hs
0 → 100644
View file @
240a13e7
module
HAL.Utils
where
import
Data.LanguageCodes
(
ISO639_1
(
..
),
language
)
import
Data.Text
qualified
as
T
import
Protolude
allLangs
::
[
ISO639_1
]
allLangs
=
enumFrom
(
toEnum
0
)
::
[
ISO639_1
]
langAbstractS
::
ISO639_1
->
Text
langAbstractS
lang
=
(
T
.
pack
$
language
lang
)
<>
"_abstract_s"
src/Tree.hs
View file @
240a13e7
...
...
@@ -2,9 +2,9 @@ module Tree where
import
Control.Lens.Getter
((
^.
))
import
Data.List.Split
(
chunksOf
)
import
Data.Map
qualified
as
Map
import
Data.Map
(
insert
)
import
Data.Map.Internal
(
merge
,
preserveMissing
,
zipWithMatched
)
import
Data.Map
.Strict
qualified
as
Map
import
Data.Map
.Strict
(
insert
)
import
Data.Map.
Strict.
Internal
(
merge
,
preserveMissing
,
zipWithMatched
)
import
Data.Text
qualified
as
T
import
Data.Text.Format
(
format
)
import
Data.Text.Lazy
qualified
as
TL
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment