Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
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
Grégoire Locqueville
haskell-gargantext
Commits
ea0fe616
Commit
ea0fe616
authored
Apr 25, 2023
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PARSERS] Iramuteq file format parser
parent
aa5bfd52
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
1 deletion
+73
-1
Iramuteq.hs
src/Gargantext/Core/Text/Corpus/Parsers/Iramuteq.hs
+73
-0
RIS.hs
src/Gargantext/Core/Text/Corpus/Parsers/RIS.hs
+0
-1
No files found.
src/Gargantext/Core/Text/Corpus/Parsers/Iramuteq.hs
0 → 100644
View file @
ea0fe616
{-|
Module : Gargantext.Core.Text.Corpus.Parsers.WOS
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Here is a longer description of this module, containing some
commentary with @some markup@.
-}
module
Gargantext.Core.Text.Corpus.Parsers.Iramuteq
(
parseIramuteqFile
,
notices
)
where
import
Control.Applicative
import
Data.Attoparsec.ByteString
(
Parser
,
takeTill
,
parseOnly
)
import
Data.Attoparsec.ByteString.Char8
(
isEndOfLine
,
takeWhile
,
endOfLine
)
import
Data.ByteString
(
ByteString
)
import
Prelude
hiding
(
takeWhile
,
take
,
concat
,
readFile
,
lines
,
concat
)
import
qualified
Data.ByteString
as
DB
parseIramuteqFile
::
String
->
IO
(
Either
String
[[(
ByteString
,
ByteString
)]])
parseIramuteqFile
fp
=
do
txts
<-
DB
.
readFile
fp
pure
$
parseOnly
notices
txts
-------------------------------------------------------------
notices
::
Parser
[[(
ByteString
,
ByteString
)]]
notices
=
do
ns
<-
(
many
notice
)
pure
ns
notice
::
Parser
[(
ByteString
,
ByteString
)]
notice
=
do
hs
<-
headers
ns
<-
takeWhile
(
/=
'*'
)
pure
$
hs
<>
[(
"text"
,
ns
)]
-----------------------------------------------------------------
headers
::
Parser
[(
ByteString
,
ByteString
)]
headers
=
parseOf
header
fields
header
::
Parser
ByteString
header
=
"**** "
*>
takeTill
isEndOfLine
<*
endOfLine
-----------------------------------------------------------------
fields
::
Parser
[(
ByteString
,
ByteString
)]
fields
=
many
(
parseOf
field
fieldTuple
)
field
::
Parser
ByteString
field
=
"*"
*>
takeWhile
(
/=
' '
)
<*
" "
<|>
"*"
*>
takeWhile
(
/=
'
\n
'
)
fieldTuple
::
Parser
(
ByteString
,
ByteString
)
fieldTuple
=
do
name
<-
takeWhile
(
/=
'_'
)
<*
"_"
rest
<-
takeWhile
(
/=
'
\n
'
)
pure
(
name
,
rest
)
-----------------------------------------------------------------
constP
::
Parser
a
->
ByteString
->
Parser
a
constP
p
t
=
case
parseOnly
p
t
of
Left
_
->
empty
Right
a
->
return
a
parseOf
::
Parser
ByteString
->
Parser
a
->
Parser
a
parseOf
ptxt
pa
=
bothParse
<|>
empty
where
bothParse
=
ptxt
>>=
constP
pa
src/Gargantext/Core/Text/Corpus/Parsers/RIS.hs
View file @
ea0fe616
...
...
@@ -16,7 +16,6 @@ citation programs to exchange data.
-}
module
Gargantext.Core.Text.Corpus.Parsers.RIS
(
parser
,
onField
,
fieldWith
,
lines
)
where
import
Data.List
(
lookup
)
...
...
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