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
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
gargantext
crawlers
hal
Commits
d54812d5
Commit
d54812d5
authored
Aug 23, 2024
by
mzheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding institutes tree
parent
1dbd9392
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
HAL.hs
src/HAL.hs
+3
-2
Document.hs
src/HAL/Doc/Document.hs
+26
-1
No files found.
src/HAL.hs
View file @
d54812d5
...
...
@@ -6,7 +6,7 @@ import Data.Aeson ( FromJSON )
import
Data.LanguageCodes
(
ISO639_1
(
..
))
import
Data.Text
qualified
as
T
import
HAL.Client
(
SortField
(
Asc
),
search
,
structure
,
searchCursor
)
import
HAL.Doc.Document
(
Document
)
import
HAL.Doc.Document
(
Document
(
..
)
)
import
HAL.Doc.Struct
(
Struct
)
import
HAL.Types
(
Response
(
..
))
import
HAL.Utils
(
langAbstractS
,
toText
)
...
...
@@ -231,7 +231,8 @@ baseFields = [ "docid"
,
"source_s"
,
"authFullName_s"
,
"authOrganism_s"
,
"structIdName_fs"
]
,
"structIdName_fs"
,
"instStructIsChildOf_fs"
]
structFields
::
Text
structFields
=
"docid,label_s,parentDocid_i"
...
...
src/HAL/Doc/Document.hs
View file @
d54812d5
...
...
@@ -26,13 +26,14 @@ data Document = Document
,
_document_source
::
Maybe
Text
,
_document_authors_names
::
[
Text
]
,
_document_authors_affiliations
::
[
Text
]
,
_document_institutes_tree
::
Map
Text
Text
,
_document_struct_id
::
[
Int
]
,
_document_original
::
Object
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
D
ocument
instance
Default
Document
where
def
=
Document
"default Id"
def
def
def
def
def
def
def
def
mempty
def
=
Document
"default Id"
def
def
def
def
def
def
def
def
def
mempty
instance
FromJSON
Document
where
parseJSON
=
withObject
"Document"
$
\
o
->
do
...
...
@@ -50,6 +51,10 @@ instance FromJSON Document where
let
_document_struct_id
=
map
fst
structIdname
let
_document_authors_affiliations
=
map
snd
structIdname
structChild
<-
o
.:?
"instStructIsChildOf_fs"
::
Parser
(
Maybe
[
Text
])
let
_document_institutes_tree
=
Map
.
fromList
$
getStructParentChild
structChild
abstracts
<-
mapM
(
\
lang
->
do
ma
<-
o
.:?
fromString
(
T
.
unpack
$
langAbstractS
lang
)
...
...
@@ -71,5 +76,25 @@ getStructIdsNames (Just idsNames) = map (\tab -> (P.read (T.unpack (P.head tab))
splitInstitutes
=
P
.
map
(
T
.
splitOn
(
T
.
pack
"_FacetSep_"
))
getStructIdsNames
Nothing
=
[]
getStructParentChild
::
Maybe
[
T
.
Text
]
->
[(
T
.
Text
,
T
.
Text
)]
getStructParentChild
(
Just
struct
)
=
map
(
\
tab
->
(
formatParent
$
P
.
last
tab
,
formatChild
$
P
.
head
tab
))
$
splitStruct
struct
where
splitStruct
::
[
T
.
Text
]
->
[[
T
.
Text
]]
splitStruct
=
P
.
map
(
T
.
splitOn
(
T
.
pack
"_JoinSep_"
))
formatChild
c
=
name
<>
" | "
<>
id
where
name
=
P
.
last
splited
id
=
P
.
head
splited
splited
=
T
.
splitOn
"_"
c
formatParent
p
=
name
<>
" | "
<>
id
where
name
=
P
.
last
splited
id
=
P
.
head
splited
splited
=
T
.
splitOn
"_FacetSep_"
p
getStructParentChild
Nothing
=
[]
instance
ToHttpApiData
Document
where
toUrlPiece
_
=
"docid,title_s,en_abstract_s,fr_abstract_s,submittedDate_s,source_s,authFullName_s,structId_i,structIdName_fs"
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