Commit 62bb742b authored by Alexandre Delanoë's avatar Alexandre Delanoë

[DATA] adding a csv corpus functions.

parent 3c62bb74
...@@ -71,7 +71,7 @@ instance Arbitrary Status where ...@@ -71,7 +71,7 @@ instance Arbitrary Status where
------------------------------------------------------------------------ ------------------------------------------------------------------------
data HyperdataDocument = HyperdataDocument { hyperdataDocument_bdd :: Maybe Text data HyperdataDocument = HyperdataDocument { hyperdataDocument_bdd :: Maybe Text
, hyperdataDocument_doi :: Maybe Text , hyperdataDocument_doi :: Maybe Int
, hyperdataDocument_url :: Maybe Text , hyperdataDocument_url :: Maybe Text
, hyperdataDocument_page :: Maybe Int , hyperdataDocument_page :: Maybe Int
, hyperdataDocument_title :: Maybe Text , hyperdataDocument_title :: Maybe Text
......
...@@ -169,6 +169,11 @@ post' = do ...@@ -169,6 +169,11 @@ post' = do
type CorpusName = Text type CorpusName = Text
-- |
-- myCorpus <- Prelude.map doc2hyperdataDocument <$> toDocs <$> snd <$> readCsv "doc/corpus_imt/Gargantext_Corpus_small.csv"
-- There is an error in the CSV parsing...
-- let myCorpus' = Prelude.filter (\n -> T.length (maybe "" identity (hyperdataDocument_title n)) > 30) myCorpus
postCorpus :: ToJSON a => CorpusName -> (a -> Text) -> [a] -> IO [Int] postCorpus :: ToJSON a => CorpusName -> (a -> Text) -> [a] -> IO [Int]
postCorpus corpusName title ns = do postCorpus corpusName title ns = do
c <- connectGargandb "gargantext.ini" c <- connectGargandb "gargantext.ini"
......
...@@ -32,6 +32,7 @@ import Data.Vector (Vector) ...@@ -32,6 +32,7 @@ import Data.Vector (Vector)
import qualified Data.Vector as V import qualified Data.Vector as V
import Safe (tailMay) import Safe (tailMay)
import Gargantext.Core.Types.Node (HyperdataDocument(..))
import Gargantext.Text import Gargantext.Text
import Gargantext.Text.Context import Gargantext.Text.Context
import Gargantext.Prelude hiding (length) import Gargantext.Prelude hiding (length)
...@@ -49,6 +50,27 @@ data Doc = Doc ...@@ -49,6 +50,27 @@ data Doc = Doc
} }
deriving (Show) deriving (Show)
--------------------------------------------------------------- ---------------------------------------------------------------
-- | Doc 2 HyperdataDocument
doc2hyperdataDocument :: Doc -> HyperdataDocument
doc2hyperdataDocument (Doc did dt ds dpy dpm dpd dab dau) =
HyperdataDocument (Just "CSV")
(Just did)
Nothing
Nothing
(Just dt)
(Just dau)
(Just ds)
(Just dab)
(Nothing)
Nothing
(Just dpy)
(Just dpm)
(Just dpd)
Nothing
Nothing
Nothing
---------------------------------------------------------------
-- | Types Conversions
toDocs :: Vector CsvDoc -> [Doc] toDocs :: Vector CsvDoc -> [Doc]
toDocs v = V.toList toDocs v = V.toList
$ V.zipWith (\nId (CsvDoc t s py pm pd abst auth) $ V.zipWith (\nId (CsvDoc t s py pm pd abst auth)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment