where
import Data.Either (partitionEithers, Either(..))
-import Debug.Trace (trace)
+-- import Debug.Trace (trace)
import Data.Map (Map)
import Data.Set (Set)
import Data.Text (Text)
buildNgramsLists :: Lang -> Int -> Int -> StopSize -> UserCorpusId -> MasterCorpusId
-> Cmd err (Map NgramsType [NgramsElement])
buildNgramsLists l n m s uCid mCid = do
- --ngTerms <- buildNgramsTermsList l n m s uCid mCid
- ngTerms <- buildNgramsTermsList' uCid (ngramsGroup l n m) (isStopTerm s . fst) 500 50
+ ngTerms <- buildNgramsTermsList l n m s uCid mCid
othersTerms <- mapM (buildNgramsOthersList uCid identity) [Authors, Sources, Institutes]
pure $ Map.unions $ othersTerms <> [ngTerms]
ngs <- groupNodesByNgramsWith groupIt <$> getNodesByNgramsUser uCid nt
let
- all' = Map.toList ngs
- pure $ (toElements GraphTerm $ take 10 all') <> (toElements CandidateTerm $ drop 10 all')
+ listSize = 9
+ all' = List.reverse $ List.sortOn (Set.size . snd . snd) $ Map.toList ngs
+ graphTerms = List.take listSize all'
+ candiTerms = List.drop listSize all'
+ pure $ Map.unionsWith (<>) [ toElements GraphTerm graphTerms
+ , toElements CandidateTerm candiTerms]
where
toElements nType x = Map.fromList [(nt, [ mkNgramsElement t nType Nothing (mSetFromList [])
| (t,_ns) <- x
toTermList :: Int -> Int -> (a -> Bool) -> [a] -> [(ListType, a)]
toTermList _ _ _ [] = []
-toTermList a b stop ns = trace ("computing toTermList") $
+toTermList a b stop ns = -- trace ("computing toTermList") $
map (toList stop CandidateTerm) xs
<> map (toList stop GraphTerm) ys
<> toTermList a b stop zs