Commit 652975a0 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'master' into bayes

parents b025b4fd c430654e
......@@ -21,5 +21,6 @@ purescript-gargantext
doc
deps
_darcs
*.pdf
# Runtime
module Paths_hastext (
version,
getBinDir, getLibDir, getDataDir, getLibexecDir,
getDataFileName, getSysconfDir
) where
import qualified Control.Exception as Exception
import Data.Version (Version(..))
import System.Environment (getEnv)
import Prelude
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
catchIO = Exception.catch
version :: Version
version = Version [0,1,0,0] []
bindir, libdir, datadir, libexecdir, sysconfdir :: FilePath
bindir = "/home/alexandre/.cabal/bin"
libdir = "/home/alexandre/.cabal/lib/x86_64-linux-ghc-7.8.3/hastext-0.1.0.0"
datadir = "/home/alexandre/.cabal/share/x86_64-linux-ghc-7.8.3/hastext-0.1.0.0"
libexecdir = "/home/alexandre/.cabal/libexec"
sysconfdir = "/home/alexandre/.cabal/etc"
getBinDir, getLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath
getBinDir = catchIO (getEnv "hastext_bindir") (\_ -> return bindir)
getLibDir = catchIO (getEnv "hastext_libdir") (\_ -> return libdir)
getDataDir = catchIO (getEnv "hastext_datadir") (\_ -> return datadir)
getLibexecDir = catchIO (getEnv "hastext_libexecdir") (\_ -> return libexecdir)
getSysconfDir = catchIO (getEnv "hastext_sysconfdir") (\_ -> return sysconfdir)
getDataFileName :: FilePath -> IO FilePath
getDataFileName name = do
dir <- getDataDir
return (dir ++ "/" ++ name)
/* DO NOT EDIT: This file is automatically generated by Cabal */
/* package base-4.7.0.1 */
#define VERSION_base "4.7.0.1"
#define MIN_VERSION_base(major1,major2,minor) (\
(major1) < 4 || \
(major1) == 4 && (major2) < 7 || \
(major1) == 4 && (major2) == 7 && (minor) <= 0)
/* tool alex-3.1.3 */
#define TOOL_VERSION_alex "3.1.3"
#define MIN_TOOL_VERSION_alex(major1,major2,minor) (\
(major1) < 3 || \
(major1) == 3 && (major2) < 1 || \
(major1) == 3 && (major2) == 1 && (minor) <= 3)
/* tool c2hs-0.17.2 */
#define TOOL_VERSION_c2hs "0.17.2"
#define MIN_TOOL_VERSION_c2hs(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 17 || \
(major1) == 0 && (major2) == 17 && (minor) <= 2)
/* tool cpphs-1.19.3 */
#define TOOL_VERSION_cpphs "1.19.3"
#define MIN_TOOL_VERSION_cpphs(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 19 || \
(major1) == 1 && (major2) == 19 && (minor) <= 3)
/* tool gcc-4.9.2 */
#define TOOL_VERSION_gcc "4.9.2"
#define MIN_TOOL_VERSION_gcc(major1,major2,minor) (\
(major1) < 4 || \
(major1) == 4 && (major2) < 9 || \
(major1) == 4 && (major2) == 9 && (minor) <= 2)
/* tool ghc-7.8.3 */
#define TOOL_VERSION_ghc "7.8.3"
#define MIN_TOOL_VERSION_ghc(major1,major2,minor) (\
(major1) < 7 || \
(major1) == 7 && (major2) < 8 || \
(major1) == 7 && (major2) == 8 && (minor) <= 3)
/* tool ghc-pkg-7.8.3 */
#define TOOL_VERSION_ghc_pkg "7.8.3"
#define MIN_TOOL_VERSION_ghc_pkg(major1,major2,minor) (\
(major1) < 7 || \
(major1) == 7 && (major2) < 8 || \
(major1) == 7 && (major2) == 8 && (minor) <= 3)
/* tool haddock-2.15.0.2 */
#define TOOL_VERSION_haddock "2.15.0.2"
#define MIN_TOOL_VERSION_haddock(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 15 || \
(major1) == 2 && (major2) == 15 && (minor) <= 0)
/* tool happy-1.19.4 */
#define TOOL_VERSION_happy "1.19.4"
#define MIN_TOOL_VERSION_happy(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 19 || \
(major1) == 1 && (major2) == 19 && (minor) <= 4)
/* tool hpc-0.67 */
#define TOOL_VERSION_hpc "0.67"
#define MIN_TOOL_VERSION_hpc(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 67 || \
(major1) == 0 && (major2) == 67 && (minor) <= 0)
/* tool hsc2hs-0.67 */
#define TOOL_VERSION_hsc2hs "0.67"
#define MIN_TOOL_VERSION_hsc2hs(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 67 || \
(major1) == 0 && (major2) == 67 && (minor) <= 0)
/* tool pkg-config-0.28 */
#define TOOL_VERSION_pkg_config "0.28"
#define MIN_TOOL_VERSION_pkg_config(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 28 || \
(major1) == 0 && (major2) == 28 && (minor) <= 0)
/* tool strip-2.25 */
#define TOOL_VERSION_strip "2.25"
#define MIN_TOOL_VERSION_strip(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 25 || \
(major1) == 2 && (major2) == 25 && (minor) <= 0)
[InstalledPackageInfo {installedPackageId = InstalledPackageId "hastext-0.1.0.0-inplace", sourcePackageId = PackageIdentifier {pkgName = PackageName "hastext", pkgVersion = Version {versionBranch = [0,1,0,0], versionTags = []}}, license = BSD3, copyright = "Copyright: (c) 2016 Alexandre Delano\235", maintainer = "alexandre+dev@delanoe.org", author = "Alexandre Delano\235", stability = "", homepage = "http://github.com/adelanoe/hastext#readme", pkgUrl = "", synopsis = "Text mining project", description = "Please see README.md", category = "Data", exposed = True, exposedModules = ["Hastext","Hastext.Db"], hiddenModules = [], trusted = False, importDirs = ["/home/alexandre/projets/hastext/dist/build"], libraryDirs = ["/home/alexandre/projets/hastext/dist/build"], hsLibraries = ["HShastext-0.1.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "base-4.7.0.1-1a55ebc8256b39ccbff004d48b3eb834"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/home/alexandre/projets/hastext/dist/doc/html/hastext/hastext.haddock"], haddockHTMLs = ["/home/alexandre/projets/hastext/dist/doc/html/hastext"]}
]
\ No newline at end of file
import Distribution.Simple; main = defaultMain
Version {versionBranch = [1,22,6,0], versionTags = []}
......@@ -49,7 +49,7 @@ import Gargantext.Database.Facet (FacetDoc, getDocFacet
import Gargantext.TextFlow
import Gargantext.Viz.Graph (Graph)
import Gargantext.Core (Lang(..))
import Gargantext.Core.Types.Main (Tree)
import Gargantext.Core.Types.Main (Tree, NodeTree)
import Gargantext.Text.Terms (TermType(..))
-------------------------------------------------------------------
-------------------------------------------------------------------
......@@ -112,7 +112,7 @@ type GraphAPI = Get '[JSON] Graph
graphAPI :: Connection -> NodeId -> Server GraphAPI
graphAPI _ _ = liftIO $ textFlow (Mono EN) (Contexts contextText)
type TreeAPI = Get '[JSON] (Tree NodeType)
type TreeAPI = Get '[JSON] (Tree NodeTree)
treeAPI :: Connection -> NodeId -> Server TreeAPI
treeAPI _ _ = undefined
......
......@@ -15,18 +15,22 @@ Portability : POSIX
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
------------------------------------------------------------------------
-----------------------------------------------------------------------
module Gargantext.Core.Types.Main where
------------------------------------------------------------------------
import Data.Aeson (FromJSON, ToJSON)
import Data.Aeson (FromJSON, ToJSON, toJSON)
import Data.Aeson as A
import Data.Aeson.TH (deriveJSON)
import Data.Eq (Eq())
import Data.Monoid ((<>))
import Data.Text (Text)
import Data.Swagger
import Gargantext.Database.Types.Node
import Gargantext.Core.Utils.Prefix (unPrefix)
import Gargantext.Prelude
import GHC.Generics (Generic)
......@@ -34,44 +38,45 @@ import Test.QuickCheck (elements)
import Test.QuickCheck.Arbitrary (Arbitrary, arbitrary)
------------------------------------------------------------------------
-- All the Database is structred like a hierarchical Tree
data Tree a = NodeT a [Tree a]
deriving (Show, Read, Eq, Generic)
instance ToJSON (Tree NodeType)
instance FromJSON (Tree NodeType)
data NodeTree = NodeTree { _nt_name :: Text
, _nt_type :: NodeType
, _nt_id :: Int
} deriving (Show, Read, Generic)
instance ToSchema (Tree NodeType)
instance Arbitrary (Tree NodeType) where
arbitrary = elements [userTree, userTree]
-- data Tree a = NodeT a [Tree a]
-- same as Data.Tree
leafT :: a -> Tree a
leafT x = NodeT x []
$(deriveJSON (unPrefix "_nt_") ''NodeTree)
------------------------------------------------------------------------
-- Garg Network is a network of all Garg nodes
--gargNetwork = undefined
-- | Garg Node is Database Schema Typed as specification
-- gargNode gathers all the Nodes of all users on one Node
gargNode :: [Tree NodeType]
gargNode :: [Tree NodeTree]
gargNode = [userTree]
-- | User Tree simplified
userTree :: Tree NodeType
userTree = NodeT NodeUser [projectTree]
userTree :: Tree NodeTree
userTree = TreeN (NodeTree "user name" NodeUser 1) $
[leafT $ NodeTree "MyPage" UserPage 0] <>
[annuaireTree, projectTree]
-- | Project Tree
projectTree :: Tree NodeType
projectTree = NodeT Project [corpusTree]
projectTree :: Tree NodeTree
projectTree = TreeN (NodeTree "Project CNRS/IMT" Project 2) [corpusTree 10 "A", corpusTree 20 "B"]
type Individu = Document
-- | Corpus Tree
corpusTree :: Tree NodeType
corpusTree = NodeT NodeCorpus ( [ leafT Document ]
<> [ leafT Lists ]
<> [ leafT Metrics ]
<> [ leafT Classification]
annuaireTree :: Tree NodeTree
annuaireTree = TreeN (NodeTree "Annuaire" Annuaire 41) ( [leafT $ NodeTree "IMT" Individu 42]
<> [leafT $ NodeTree "CNRS" Individu 43]
)
corpusTree :: NodeId -> Text -> Tree NodeTree
corpusTree nId t = TreeN (NodeTree ("Corpus " <> t) NodeCorpus nId) ( [ leafT $ NodeTree "Documents" Document (nId +1)]
-- <> [ leafT $ NodeTree "My lists" Lists 5]
-- <> [ leafT (NodeTree "Metrics A" Metrics 6) ]
-- <> [ leafT (NodeTree "Class A" Classification 7)]
)
-- TODO make instances of Nodes
......@@ -92,7 +97,6 @@ data Lists = StopList | MainList | MapList | GroupList
-- | Community Manager Use Case
type Annuaire = NodeCorpus
type Individu = Document
-- | Favorites Node enable Node categorization
type Favorites = Node HyperdataFavorites
......@@ -135,3 +139,24 @@ type ParentId = NodeId
type Limit = Int
type Offset = Int
------------------------------------------------------------------------
-- All the Database is structred like a hierarchical Tree
data Tree a = TreeN a [Tree a]
deriving (Show, Read, Eq, Generic)
instance ToJSON (Tree NodeTree) where
toJSON (TreeN node nodes) =
object ["node" A..= toJSON node, "children" A..= toJSON nodes]
instance FromJSON (Tree NodeTree)
instance ToSchema NodeTree
instance ToSchema (Tree NodeTree)
instance Arbitrary (Tree NodeTree) where
arbitrary = elements [userTree, userTree]
-- data Tree a = NodeT a [Tree a]
-- same as Data.Tree
leafT :: a -> Tree a
leafT x = TreeN x []
......@@ -274,7 +274,7 @@ type NodeCorpus = Node HyperdataCorpus
type Document = Node HyperdataDocument
------------------------------------------------------------------------
data NodeType = NodeUser | Project | Folder | NodeCorpus | Annuaire | Document | UserPage | DocumentCopy | Favorites
data NodeType = NodeUser | Project | Folder | NodeCorpus | Annuaire | Document | Individu | UserPage | DocumentCopy | Favorites
| Classification
| Lists
| Metrics | Occurrences
......
......@@ -36,7 +36,7 @@ import Protolude ( Bool(True, False), Int, Int64, Double, Integer
, Fractional, Num, Maybe(Just,Nothing)
, Enum, Bounded, Float
, Floating, Char, IO
, pure, (>>=), (=<<), (<*>), (<$>), panic
, pure, (>>=), (=<<), (<*>), (<$>)
, putStrLn
, head, flip
, Ord, Integral, Foldable, RealFrac, Monad, filter
......@@ -55,6 +55,7 @@ import Protolude ( Bool(True, False), Int, Int64, Double, Integer
, IO()
, compare
, on
, panic
)
-- TODO import functions optimized in Utils.Count
......
......@@ -13,7 +13,7 @@ Mono-terms are Nterms where n == 1.
{-# LANGUAGE NoImplicitPrelude #-}
module Gargantext.Text.Terms.Mono (monoTerms, monoTexts, monoTextsBySentence)
module Gargantext.Text.Terms.Mono (monoTerms, monoTexts, monoTextsBySentence, words)
where
import Prelude (String)
......@@ -34,10 +34,12 @@ import Gargantext.Prelude
-- | TODO remove Num ?
--isGram c = isAlphaNum c
words :: Text -> [Text]
words = monoTexts
-- | Sentence split separators
isSep :: Char -> Bool
isSep = (`elem` (",.:;?!(){}[]\"" :: String))
isSep = (`elem` (",.:;?!(){}[]\"\'" :: String))
monoTerms :: Lang -> Text -> [Terms]
monoTerms l txt = map (monoText2term l) $ monoTexts txt
......
-- | Cesar et Cleôpatre
-- Exemple de phylomemie
-- French without accents
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleContexts #-}
module Gargantext.Viz.Phylo.Example where
import qualified Data.List as DL
import Data.String (String)
import Data.Text (Text, pack, unwords, toLower)
import Data.Tuple.Extra (both)
import Data.Map (Map)
import qualified Data.Map as DM
import Gargantext.Text.Terms.Mono (monoTexts)
import Gargantext.Prelude
------------------------------------------------------------------------
type Histoire = [Event]
data Event = Event {date:: Double, text :: Text}
deriving (Show)
type MapList = [Text]
type PeriodeSize = Int
-- data Periodes b a = Map (b,b) a
------------------------------------------------------------------------
toPeriodes :: (Enum b, Fractional b, Ord b) => (t -> b) -> b -> [t] -> Map (b, b) [t]
toPeriodes _ _ [] = panic $ pack "Empty history can not have any periode"
toPeriodes f s hs = periodes f st hs
where
hs' = DL.sortOn f hs
st = steps s $ both f (DL.head hs', DL.last hs')
periodes :: Ord b => (t -> b) -> [(b, b)] -> [t] -> Map (b, b) [t]
periodes f ds h = DM.fromList $ zip ds $ periodes' f ds h
periodes' :: Ord b => (t -> b) -> [(b, b)] -> [t] -> [[t]]
periodes' _ [] _ = []
periodes' f [a] h = [x] <> [y]
where
(x,y) = periode f a h
periodes' f (a:b:bs) h = [x] <> periodes' f (b:bs) y
where
(x,y) = periode f a h
periode :: Ord b => (t -> b) -> (b, b) -> [t] -> ([t],[t])
periode f (start,end) h = DL.partition (\d -> f d >= start && f d <= end) h
------------------------------------------------------------------------
steps :: (Ord a, Fractional a, Enum a) => a -> (a, a) -> [(a, a)]
steps s (b,e) = zip (DL.init ss) (DL.tail ss)
where
ss = steps' s (b,e)
steps' :: (Enum b, Fractional b, Ord b) => b -> (b, b) -> [b]
steps' s (b,e) = case s > 0 of
False -> panic $ pack "Steps size can not be < 0"
True -> steps'' s (b,e)
steps'' :: (Fractional b, Enum b) => b -> (b, b) -> [b]
steps'' s (start,end) = map (\s' -> s' * s + start) $ [0 .. end']
where
end' = ((end + 1)- start) / s
------------------------------------------------------------------------
cleanHistoire :: MapList -> Histoire -> Histoire
cleanHistoire ml = map (\(Event d t) -> Event d (unwords $ filter (\x -> elem x ml) $ monoTexts t))
mapList :: [Text]
mapList = map (toLower . pack) actants
actants :: [String]
actants = [ "Cleopatre" , "Ptolemee", "Ptolemee-XIII", "Ptolemee-XIV"
, "Marc-Antoine", "Cesar" , "Antoine" , "Octave" , "Rome"
, "Alexandrie" , "Auguste" , "Pompee" , "Cassius" , "Brutus"]
phyloCorpus :: Histoire
phyloCorpus = map (\(d,t) -> Event d (pack t)) corpus
corpus :: [(Double, String)]
corpus = [ (-51,"Cleopatre règne sur l’egypte entre 51 et 30 av. J.-C. avec ses frères-epoux Ptolemee-XIII et Ptolemee-XIV, puis aux côtes du general romain Marc-Antoine. Elle est celèbre pour avoir ete la compagne de Jules Cesar puis d'Antoine, avec lesquels elle a eu plusieurs enfants. Partie prenante dans la guerre civile opposant Antoine à Octave, elle est vaincue à la bataille d'Actium en 31 av. J.-C. Sa defaite va permettre aux Romains de mener à bien la conquête de l’egypte, evenement qui marquera la fin de l'epoque hellenistique."), (-40,"Il existe relativement peu d'informations sur son sejour à Rome, au lendemain de l'assassinat de Cesar, ou sur la periode passee à Alexandrie durant l'absence d'Antoine, entre -40 et -37."), (-48,"L'historiographie antique lui est globalement defavorable car inspiree par son vainqueur, l'empereur Auguste, et par son entourage, dont l'interêt est de la noircir, afin d'en faire l'adversaire malfaisant de Rome et le mauvais genie d'Antoine. On observe par ailleurs que Cesar ne fait aucune mention de sa liaison avec elle dans les Commentaires sur la Guerre civile"), (-69,"Cleopatre est nee au cours de l'hiver -69/-686 probablement à Alexandrie."), (-48,"Pompee a en effet ete le protecteur de Ptolemee XII, le père de Cleopatre et de Ptolemee-XIII dont il se considère comme le tuteur."), (-48,"Ptolemee-XIII et Cleopatre auraient d'ailleurs aide Pompee par l'envoi d'une flotte de soixante navires."), (-48,"Mais le jeune roi Ptolemee-XIII et ses conseillers jugent sa cause perdue et pensent s'attirer les bonnes graces du vainqueur en le faisant assassiner à peine a-t-il pose le pied sur le sol egyptien, près de Peluse, le 30 juillet 48 av. J.-C., sous les yeux de son entourage."), (-48,"Cesar fait enterrer la tête de Pompee dans le bosquet de Nemesis en bordure du mur est de l'enceinte d'Alexandrie. Pour autant la mort de Pompee est une aubaine pour Cesar qui tente par ailleurs de profiter des querelles dynastiques pour annexer l’egypte."), (-48,"Il est difficile de se prononcer clairement sur les raisons qui ont pousse Cesar à s'attarder à Alexandrie. Il y a des raisons politiques, mais aussi des raisons plus sentimentales (Cleopatre ?). Il tente d'abord d'obtenir le remboursement de dettes que Ptolemee XII"), (-46,"Les deux souverains sont convoques par Cesar au palais royal d'Alexandrie. Ptolemee-XIII s'y rend après diverses tergiversations ainsi que Cleopatre."), (-47,"A Rome, Cleopatre epouse alors un autre de ses frères cadets, à Alexandrie, Ptolemee-XIV, sur l'injonction de Jules Cesar"), (-46,"Cesar a-t-il comme objectif de montrer ce qu'il en coûte de se revolter contre Rome en faisant figurer dans son triomphe la sœur de Cleopatre et de Ptolemee-XIV, Arsinoe, qui s'est fait reconnaître reine par les troupes de Ptolemee-XIII ?"), (-44,"Au debut de l'annee -44, Cesar est assassine par Brutus. Profitant de la situation confuse qui s'ensuit, Cleopatre quitte alors Rome à la mi-avril, faisant escale en Grèce. Elle parvient à Alexandrie en juillet -44."), (-44,"La guerre que se livrent les assassins de Cesar, Cassius et Brutus et ses heritiers, Octave et Marc-Antoine, oblige Cleopatre à des contorsions diplomatiques."), (-41,"Nous ignorons depuis quand Cleopatre, agee de 29 ans en -41, et Marc-Antoine, qui a une quarantaine d'annees, se connaissent. Marc-Antoine est l'un des officiers qui ont participe au retablissement de Ptolemee XII. Il est plus vraisemblable qu'ils se soient frequentes lors du sejour à Rome de Cleopatre."), (-42,"Brutus tient la Grèce tandis que Cassius s'installe en Syrie. Le gouverneur de Cleopatre à Chypre, Serapion, vient en aide à Cassius."), (-42,"Cassius aurait envisage de s'emparer d'Alexandrie quand le 'debarquement' en Grèce d'Antoine et d'Octave l'oblige à renoncer à ses projets")]
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