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
157
Issues
157
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
haskell-gargantext
Commits
8ae401ed
Commit
8ae401ed
authored
Nov 15, 2017
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[READING]
parent
28461a06
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
25 deletions
+30
-25
Node.hs
src/Data/Gargantext/Database/Node.hs
+0
-2
WOS.hs
src/Data/Gargantext/Parsers/WOS.hs
+30
-23
No files found.
src/Data/Gargantext/Database/Node.hs
View file @
8ae401ed
...
...
@@ -84,8 +84,6 @@ nodeTable = Table "nodes" (pNode Node { node_id = optional "id"
)
selectNodes
::
Column
PGInt4
->
Query
(
Column
PGText
)
selectNodes
node_id
=
proc
()
->
do
(
Node
n_id
_tn
_u
_p
n
_d
_h
)
<-
queryNodeTable
-<
()
...
...
src/Data/Gargantext/Parsers/WOS.hs
View file @
8ae401ed
...
...
@@ -27,27 +27,13 @@ import Path.IO (resolveFile')
-- import qualified Data.ByteString.Lazy as B
import
Control.Applicative
(
(
<$>
)
)
zipFiles
::
FilePath
->
IO
[
ByteString
]
zipFiles
fp
=
do
path
<-
resolveFile'
fp
entries
<-
withArchive
path
(
DM
.
keys
<$>
getEntries
)
bs
<-
mapConcurrently
(
\
s
->
withArchive
path
(
getEntry
s
))
entries
pure
bs
parseFile
::
ParserType
->
ByteString
->
IO
Int
parseFile
p
x
=
case
runParser
p
x
of
Left
_
->
pure
0
Right
r
->
pure
$
length
r
testWos
::
FilePath
->
IO
[
Int
]
testWos
fp
=
join
$
mapConcurrently
(
parseFile
WOS
)
<$>
zipFiles
fp
-- type Parser a = a -> Text -> [Document]
data
ParserType
=
WOS
|
CSV
wosParser
::
Parser
[
Maybe
[
ByteString
]]
type
WosDoc
=
ByteString
wosParser
::
Parser
[
Maybe
[
WosDoc
]]
wosParser
=
do
-- TODO Warning if version /= 1.0
-- FIXME anyChar (string ..) /= exact string "\nVR 1.0" ?
...
...
@@ -55,13 +41,15 @@ wosParser = do
ns
<-
many1
wosNotice
<*
(
string
$
pack
"
\n
EF"
)
return
ns
wosNotice
::
Parser
(
Maybe
[
WosDoc
])
wosNotice
=
startNotice
*>
wosFields
<*
endNotice
endNotice
::
Parser
[
Char
]
endNotice
=
manyTill
anyChar
(
string
$
pack
"
\n
ER
\n
"
)
startNotice
::
Parser
ByteString
startNotice
=
"
\n
PT "
*>
takeTill
isEndOfLine
wosNotice
::
Parser
(
Maybe
[
ByteString
])
wosNotice
=
do
n
<-
startNotice
*>
wosFields
<*
manyTill
anyChar
(
string
$
pack
"
\n
ER
\n
"
)
return
n
field'
::
Parser
(
ByteString
,
[
ByteString
])
field'
=
do
...
...
@@ -101,7 +89,7 @@ wosLines = many line
line
::
Parser
ByteString
line
=
"
\n
"
*>
takeTill
isEndOfLine
runParser
::
ParserType
->
ByteString
->
Either
String
[
Maybe
[
ByteString
]]
runParser
::
ParserType
->
ByteString
->
Either
String
[
Maybe
[
WosDoc
]]
runParser
p
x
=
parseOnly
parser
x
where
parser
=
case
p
of
...
...
@@ -111,3 +99,22 @@ runParser p x = parseOnly parser x
-- isTokenChar :: Word8 -> Bool
-- isTokenChar = inClass "!#$%&'()*+./0-9:<=>?@a-zA-Z[]^_`{|}~-\n"
zipFiles
::
FilePath
->
IO
[
ByteString
]
zipFiles
fp
=
do
path
<-
resolveFile'
fp
entries
<-
withArchive
path
(
DM
.
keys
<$>
getEntries
)
bs
<-
mapConcurrently
(
\
s
->
withArchive
path
(
getEntry
s
))
entries
pure
bs
parseFile
::
ParserType
->
ByteString
->
IO
Int
parseFile
p
x
=
case
runParser
p
x
of
Left
_
->
pure
0
Right
r
->
pure
$
length
r
testWos
::
FilePath
->
IO
[
Int
]
testWos
fp
=
join
$
mapConcurrently
(
parseFile
WOS
)
<$>
zipFiles
fp
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