Commit 04e82dd6 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] Maybe Lang

parent 13b5d6a1
Pipeline #4417 passed with stages
in 13 minutes and 29 seconds
......@@ -25,7 +25,7 @@ import Data.Set (Set)
import Data.Text (Text, concat, pack, splitOn)
import Data.Vector (Vector)
import Gargantext.API.Admin.EnvTypes (Env, GargJob(..))
import Gargantext.Core (Lang)
import Gargantext.Core (Lang(EN))
import Gargantext.API.Admin.Orchestrator.Types
import Gargantext.API.Ngrams (setListNgrams)
import Gargantext.API.Ngrams.List.Types
......@@ -157,7 +157,7 @@ reIndexWith :: ( HasNodeStory env err m
reIndexWith cId lId nt lts = do
-- printDebug "(cId,lId,nt,lts)" (cId, lId, nt, lts)
corpus_node <- getNodeWith cId (Proxy @ HyperdataCorpus)
let corpusLang = view (node_hyperdata . to _hc_lang) corpus_node
let corpusLang = fromMaybe EN $ view (node_hyperdata . to _hc_lang) corpus_node
-- Getting [NgramsTerm]
ts <- List.concat
......
......@@ -23,5 +23,5 @@ addLanguageToCorpus :: (FlowCmdM env err m, MonadJobStatus m)
-> m ()
addLanguageToCorpus cId lang = do
hyperNode <- getNodeWith cId (Proxy @HyperdataCorpus)
let hyperNode' = hyperNode & over node_hyperdata (\corpus -> corpus { _hc_lang = lang })
let hyperNode' = hyperNode & over node_hyperdata (\corpus -> corpus { _hc_lang = Just lang })
void $ updateHyperdata cId hyperNode'
......@@ -27,7 +27,7 @@ import Gargantext.API.Ngrams.Prelude (getTermList)
import Gargantext.API.Ngrams.Types (NgramsTerm(..))
import Gargantext.API.Prelude (GargNoServer)
import Gargantext.Core.Text.Terms.WithList (Patterns, buildPatterns, termsInText)
import Gargantext.Core (Lang)
import Gargantext.Core (Lang(EN))
import Gargantext.Core.Types (Context)
-- import Gargantext.Core.Types.Individu (User(..))
import Gargantext.Core.Types.Main (ListType(MapTerm))
......@@ -114,7 +114,7 @@ corpusIdtoDocuments timeUnit corpusId = do
let patterns = case termList of
Nothing -> panic "[G.C.V.Phylo.API] no termList found"
Just termList' -> buildPatterns termList'
pure $ map (toPhyloDocs corpusLang patterns timeUnit) (map _context_hyperdata docs)
pure $ map (toPhyloDocs (fromMaybe EN corpusLang) patterns timeUnit) (map _context_hyperdata docs)
termsInText' :: Lang -> Patterns -> Text -> [Text]
termsInText' lang p t = (map fst) $ termsInText lang p t
......
......@@ -40,6 +40,7 @@ import Gargantext.Database.Schema.Node
import Gargantext.Database.Query.Table.NodeContext (selectDocs)
import Gargantext.Core.Types
import Gargantext.Core (HasDBid)
import Gargantext.Core (Lang(EN))
-- import Gargantext.Core.Viz.Phylo.LevelMaker (toPhylo)
-- import Gargantext.Core.Viz.Phylo.Tools
......@@ -57,7 +58,7 @@ flowPhylo :: (FlowCmdM env err m, HasDBid NodeType)
flowPhylo cId = do
corpus_node <- getNodeWith cId (Proxy @ HyperdataCorpus)
let lang = view (node_hyperdata . to _hc_lang) corpus_node
let lang = fromMaybe EN $ view (node_hyperdata . to _hc_lang) corpus_node
Please register or sign in to reply
list <- defaultList cId
termList <- HashMap.toList <$> getTermsWith (Text.words . unNgramsTerm) [list] NgramsTerms (Set.singleton MapTerm)
......
......@@ -33,7 +33,7 @@ data HyperdataCorpus =
, _hc_pubmed_api_key :: Maybe APIKey
-- | The language for the corpus. It defaults to
-- 'defaultLanguage' if we don't know which language it is.
, _hc_lang :: !Lang
, _hc_lang :: Maybe Lang
}
deriving (Generic)
......@@ -49,7 +49,7 @@ defaultHyperdataCorpus =
(JsonField "Title" "Descr" "Bool query" "Authors")
]
, _hc_pubmed_api_key = Nothing
, _hc_lang = defaultLanguage
, _hc_lang = Just defaultLanguage
}
------------------------------------------------------------------------
......
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