Commit 8b95cfb2 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[DB][FLOW] bug fixed, flow seems ok.

parent 5a2df841
...@@ -80,7 +80,6 @@ flowDatabase ff fp cName = do ...@@ -80,7 +80,6 @@ flowDatabase ff fp cName = do
let docsWithNgrams = documentIdWithNgrams extractNgramsT documentsWithId let docsWithNgrams = documentIdWithNgrams extractNgramsT documentsWithId
printDebug "docsWithNgrams" docsWithNgrams printDebug "docsWithNgrams" docsWithNgrams
{-
let maps = mapNodeIdNgrams docsWithNgrams let maps = mapNodeIdNgrams docsWithNgrams
printDebug "maps" (maps) printDebug "maps" (maps)
...@@ -95,6 +94,7 @@ flowDatabase ff fp cName = do ...@@ -95,6 +94,7 @@ flowDatabase ff fp cName = do
printDebug "Docs IDs : " (length idsRepeat) printDebug "Docs IDs : " (length idsRepeat)
{-
-} -}
(_, _, corpusId2) <- subFlow "user1" cName (_, _, corpusId2) <- subFlow "user1" cName
{- {-
......
...@@ -77,7 +77,7 @@ import qualified Database.PostgreSQL.Simple as DPS ...@@ -77,7 +77,7 @@ import qualified Database.PostgreSQL.Simple as DPS
-- ngrams in authors field of document has Authors Type -- ngrams in authors field of document has Authors Type
-- ngrams in text (title or abstract) of documents has Terms Type -- ngrams in text (title or abstract) of documents has Terms Type
data NgramsType = Authors | Institutes | Sources | Terms data NgramsType = Authors | Institutes | Sources | Terms
deriving (Eq, Show) deriving (Eq, Show, Ord)
ngramsTypeId :: NgramsType -> Int ngramsTypeId :: NgramsType -> Int
ngramsTypeId Authors = 1 ngramsTypeId Authors = 1
...@@ -93,11 +93,8 @@ type Size = Int ...@@ -93,11 +93,8 @@ type Size = Int
-- | TODO put it in Gargantext.Text.Ngrams -- | TODO put it in Gargantext.Text.Ngrams
data Ngrams = Ngrams { _ngramsTerms :: Text data Ngrams = Ngrams { _ngramsTerms :: Text
, _ngramsSize :: Int , _ngramsSize :: Int
} deriving (Generic, Show) } deriving (Generic, Show, Eq, Ord)
instance Eq Ngrams where
(==) = (==)
instance Ord Ngrams where
compare = compare
makeLenses ''Ngrams makeLenses ''Ngrams
instance DPS.ToRow Ngrams where instance DPS.ToRow Ngrams where
toRow (Ngrams t s) = [toField t, toField s] toRow (Ngrams t s) = [toField t, toField s]
...@@ -111,37 +108,23 @@ text2ngrams txt = Ngrams txt $ length $ splitOn " " txt ...@@ -111,37 +108,23 @@ text2ngrams txt = Ngrams txt $ length $ splitOn " " txt
data NgramsT a = data NgramsT a =
NgramsT { _ngramsType :: NgramsType NgramsT { _ngramsType :: NgramsType
, _ngramsT :: a , _ngramsT :: a
} deriving (Generic, Show) } deriving (Generic, Show, Eq, Ord)
instance Eq (NgramsT a)
where (==) = (==)
-- where NgramsT
-- t1 == t2
-- n1 == n2
instance Ord (NgramsT a) where compare = compare
makeLenses ''NgramsT makeLenses ''NgramsT
----------------------------------------------------------------------- -----------------------------------------------------------------------
data NgramsIndexed = data NgramsIndexed =
NgramsIndexed NgramsIndexed
{ _ngrams :: Ngrams { _ngrams :: Ngrams
, _ngramsId :: NgramsId , _ngramsId :: NgramsId
} deriving (Show, Generic) } deriving (Show, Generic, Eq, Ord)
instance Eq NgramsIndexed where
(==) = (==)
instance Ord NgramsIndexed where
compare = compare
makeLenses ''NgramsIndexed makeLenses ''NgramsIndexed
------------------------------------------------------------------------ ------------------------------------------------------------------------
data NgramIds = data NgramIds =
NgramIds NgramIds
{ ngramId :: Int { ngramId :: Int
, ngramTerms :: Text , ngramTerms :: Text
} deriving (Show, Generic) } deriving (Show, Generic, Eq, Ord)
instance DPS.FromRow NgramIds where instance DPS.FromRow NgramIds where
fromRow = NgramIds <$> field <*> field fromRow = NgramIds <$> field <*> field
...@@ -163,7 +146,6 @@ insertNgrams' ns = mkCmd $ \conn -> DPS.query conn queryInsertNgrams (DPS.Only $ ...@@ -163,7 +146,6 @@ insertNgrams' ns = mkCmd $ \conn -> DPS.query conn queryInsertNgrams (DPS.Only $
where where
fields = map (\t -> QualifiedIdentifier Nothing t) ["text", "int4"] fields = map (\t -> QualifiedIdentifier Nothing t) ["text", "int4"]
insertNgrams_Debug :: [(NgramsTerms, Size)] -> Cmd ByteString insertNgrams_Debug :: [(NgramsTerms, Size)] -> Cmd ByteString
insertNgrams_Debug ns = mkCmd $ \conn -> DPS.formatQuery conn queryInsertNgrams (DPS.Only $ Values fields ns) insertNgrams_Debug ns = mkCmd $ \conn -> DPS.formatQuery conn queryInsertNgrams (DPS.Only $ Values fields ns)
where where
......
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