Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
138
Issues
138
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
2b00da3a
Commit
2b00da3a
authored
Mar 25, 2019
by
James Laver
Committed by
Alexandre Delanoë
Apr 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
show some progress to the rest of the team
parent
e4c4620e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
385 additions
and
2 deletions
+385
-2
.gitignore
.gitignore
+2
-2
README.md
README.md
+63
-0
packages.dhall
packages.dhall
+131
-0
psc-package.json
psc-package.json
+2
-0
spago.dhall
spago.dhall
+26
-0
AnnotatedRun.purs
src/Gargantext/Components/Annotated/AnnotatedRun.purs
+70
-0
ContextMenu.purs
src/Gargantext/Components/ContextMenu/ContextMenu.purs
+76
-0
Types.purs
src/Gargantext/Types.purs
+8
-0
Reactil.purs
src/Gargantext/Utils/Reactil.purs
+7
-0
No files found.
.gitignore
View file @
2b00da3a
...
...
@@ -3,8 +3,8 @@
/.pulp-cache/
/output/
/generated-docs/
/.psc-package/
/.psc*
/.purs*
/.psa*
/dist/css/*map
bundle.js
/.spago
README.md
View file @
2b00da3a
...
...
@@ -29,3 +29,66 @@ In one command:
## Note to the contributors
Please follow CONTRIBUTING.md
## Introduction
Making sense of out text isn't actually that hard, but it does require
a little background knowledge to understand.x
### N-grams
N-grams are at the heart of how Gargantext makes sense out of text.
There are two common meanings in the literature for n-gram:
-
a sequence of
`n`
characters
-
a sequence of
`n`
words
Gargantext is focused on words. Here are some example word n-grams;
-
`coffee`
(unigram or 1-gram)
-
`need coffee`
(bigram or 2-gram)
-
`one coffee please`
(trigram or 3-gram)
-
`here is your coffee`
(4-gram)
-
`i need some more coffee`
(5-gram)
N-grams are matched case insensitively and across whole words. Examples:
| Text | N-gram | Matches |
|--------------|--------------|----------------------|
|
`Coffee cup`
|
`coffee`
| YES |
|
`Coffee cup`
|
`off`
| NO, not a whole word |
|
`Coffee cup`
|
`coffee cup`
| YES |
You may read more about n-grams
[
on wikipedia
](
https://en.wikipedia.org/wiki/N-gram
)
.
Gargantext allows you to define n-grams interactively in your browser
and explore the relationships they uncover across a corpus of text.
Various metrics can be applied to n-grams, the most common of which is
the number of times an n-gram appears in a document.
## Glossary
document
: One or more texts comprising a single logical document
field
: A portion of a document, e.g.
`title`
,
`abstract`
,
`body`
corpus
: A collection of documents
n-gram/ngram
: A word or words to be indexed, consisting of
`n`
words.
This technically includes skip-grams, but in the general case
the words will be contiguous.
unigram/1-gram
: A one-word n-gram, e.g.
`cow`
,
`coffee`
bigram/2-gram
: A two-word n-gram, e.g.
`coffee cup`
trigram
: A three-word n-gram, e.g.
`coffee cup holder`
<!-- skip-grams are not yet supported -->
<!-- skip-gram -->
<!-- : An n-gram where the words are not all adjacent -->
<!-- k-skip-n-gram -->
<!-- : An n-gram where the words are at most distance k from each other -->
packages.dhall
0 → 100644
View file @
2b00da3a
{-
Welcome to Spacchetti local packages!
Below are instructions for how to edit this file for most use
cases, so that you don't need to know Dhall to use it.
## Warning: Don't Move This Top-Level Comment!
Due to how `dhall format` currently works, this comment's
instructions cannot appear near corresponding sections below
because `dhall format` will delete the comment. However,
it will not delete a top-level comment like this one.
## Use Cases
Most will want to do one or both of these options:
1. Override/Patch a package's dependency
2. Add a package not already in the default package set
This file will continue to work whether you use one or both options.
Instructions for each option are explained below.
### Overriding/Patching a package
Purpose:
- Change a package's dependency to a newer/older release than the
default package set's release
- Use your own modified version of some dependency that may
include new API, changed API, removed API by
using your custom git repo of the library rather than
the package set's repo
Syntax:
Replace the overrides' "{=}" (an empty record) with the following idea
The "//" or "⫽" means "merge these two records and
when they have the same value, use the one on the right:"
-------------------------------
let override =
{ packageName =
upstream.packageName ⫽ { updateEntity1 = "new value", updateEntity2 = "new value" }
, packageName =
upstream.packageName ⫽ { version = "v4.0.0" }
, packageName =
upstream.packageName // { repo = "https://www.example.com/path/to/new/repo.git" }
}
-------------------------------
Example:
-------------------------------
let overrides =
{ halogen =
upstream.halogen ⫽ { version = "master" }
, halogen-vdom =
upstream.halogen-vdom ⫽ { version = "v4.0.0" }
}
-------------------------------
### Additions
Purpose:
- Add packages that aren't alread included in the default package set
Syntax:
Replace the additions' "{=}" (an empty record) with the following idea:
-------------------------------
let additions =
{ "package-name" =
mkPackage
[ "dependency1"
, "dependency2"
]
"https://example.com/path/to/git/repo.git"
"tag ('v4.0.0') or branch ('master')"
, "package-name" =
mkPackage
[ "dependency1"
, "dependency2"
]
"https://example.com/path/to/git/repo.git"
"tag ('v4.0.0') or branch ('master')"
, etc.
}
-------------------------------
Example:
-------------------------------
let additions =
{ benchotron =
mkPackage
[ "arrays"
, "exists"
, "profunctor"
, "strings"
, "quickcheck"
, "lcg"
, "transformers"
, "foldable-traversable"
, "exceptions"
, "node-fs"
, "node-buffer"
, "node-readline"
, "datetime"
, "now"
]
"https://github.com/hdgarrood/purescript-benchotron.git"
"v7.0.0"
}
-------------------------------
-}
let mkPackage =
https://raw.githubusercontent.com/spacchetti/spacchetti/20181209/src/mkPackage.dhall sha256:8e1c6636f8a089f972b21cde0cef4b33fa36a2e503ad4c77928aabf92d2d4ec9
let upstream =
https://raw.githubusercontent.com/spacchetti/spacchetti/20181209/src/packages.dhall sha256:c63285af67ae74feb2f6eb67521712441928d2726ea10e2040774849ca765027
let overrides =
{ thermite =
mkPackage
[ "aff", "coroutines", "web-dom", "freet", "profunctor-lenses", "react", "react-dom" ]
"https://github.com/np/purescript-thermite.git"
"hide" }
let additions =
{ sequences =
mkPackage
[ "prelude", "unsafe-coerce", "partial", "unfoldable", "lazy", "arrays", "profunctor", "maybe", "tuples", "newtype" ]
"https://github.com/hdgarrood.git"
"v2.1.0" }
in upstream ⫽ overrides ⫽ additions
psc-package.json
View file @
2b00da3a
...
...
@@ -21,6 +21,8 @@
"random"
,
"affjax"
,
"console"
,
"strings"
,
"string-parsers"
,
"prelude"
]
}
spago.dhall
0 → 100644
View file @
2b00da3a
{-
Welcome to a Spago project!
You can edit this file as you like.
-}
{ name =
"my-project"
, dependencies =
[ "js-timers"
, "psci-support"
, "css"
, "generics-rep"
, "routing"
, "foreign-object"
, "argonaut"
, "effect"
, "web-html"
, "thermite"
, "integers"
, "random"
, "affjax"
, "console"
-- , "sequences"
, "strings"
, "string-parsers"
, "prelude" ]
, packages = ./packages.dhall }
src/Gargantext/Components/Annotated/AnnotatedRun.purs
0 → 100644
View file @
2b00da3a
-- | The AnnotatedRun Component renders an ngram run with appropriate
-- | highlighting and tooltip
module Gargantext.Components.Annotated.AnnotatedRun where
import Prelude hiding (div)
import Data.Maybe (Maybe(..))
import Data.Unit (Unit, unit)
import Data.Array as A
import Data.Lens (Lens', Prism', over, view)
import Data.List (List, mapWithIndex, toUnfoldable, sortBy)
import Data.Ordering (Ordering(..))
import Data.String.Common (joinWith)
import Data.String.CodeUnits as CU
import Data.String.Regex as Regex
import Data.Tuple (Tuple(..))
import React (ReactElement)
import React.DOM (span, text)
import React.DOM.Props (Props, className, title, style, onClick)
import Thermite ( PerformAction, Render, Spec
, _render, modifyState, focus
, simpleSpec, withState)
import Gargantext.Types (Term(..), TermList(..), termListName)
import Gargantext.Utils.Reactil (wrap)
-- TODO: Support multiple lists (see the large quantities of commented out code)
-- names :: forall f. Foldable f, => f String -> Array String
-- names = map \(OccurrenceList o) -> o.name
-- tooltip :: Array String -> Maybe String
-- tooltip = help . A.fromFoldable
-- where help [] = Nothing
-- help names = Just $ prelude <> joinWith ", " names
-- where prelude = "Occurs in " <> (show $ A.length names) <> " lists: "
-- wrapColour :: Colour -> ReactElement -> ReactElement
-- wrapColour colour = wrap $ div [color (show colour), opacity "0.8"]
newtype Run = Run { text :: String, list :: Maybe TermList } -- lists :: Array TermList }
-- TODO: Context Menu
-- | A Blank Run is not part an n-gram, but it does have a context menu
renderBlank :: Run -> ReactElement
renderBlank = wrap $ span [className "run run-blank"] <<< text
-- TODO: Context Menu
renderHilite :: Run -> ReactElement
renderHilite r = span [className "run run-pretty", title tooltip] [text r.text]
-- (wrap wrapping) $ foldl wrapColour head r.lists
where tooltip = "Occurs in the " <> termListName r.list
-- lists = names r.lists
-- head = span [className "run run-pretty", title (tooltip lists)] [text r.text]
-- wrapping = span [className "run run-pretty"]
render :: Run -> ReactElement
render r
| r.lists == [] = renderBlank r.text
| otherwise = renderHilite r
data Action = AddTerm Term | RemoveTerm Term
termStyle :: TermList -> Props
termStyle GraphTerm = style {color: "green"}
termStyle StopTerm = style {color: "red", textDecoration : "line-through"}
termStyle CandidateTerm = style {color: "black"}
-- annotatedRun ::
-- Spec Unit Run Action
src/Gargantext/Components/ContextMenu/ContextMenu.purs
0 → 100644
View file @
2b00da3a
-- | The ContextMeny component renders a generic context menu
-- |
module Gargantext.Component.ContextMenu.ContextMenu
(MenuProps, Action(..), separator) where
import Prelude hiding (div)
import Effect (Effect)
import React
( class ReactComponentSpec
, ReactClass, ReactElement, ReactClassConstructor, Children
, component, createElement )
import React.DOM (a, div, li, ul')
import React.DOM as DOM -- for Props
import React.DOM.Props (className, onContextMenu, onMouseOut, onBlur)
import Thermite (Render, PerformAction, simpleSpec, modifyState_,
createReactSpec, defaultRender)
import Gargantext.Utils.Reactil (wrap)
separator :: ReactElement
separator = div [ className "context-menu-separator" ] []
newtype State = State { open :: Boolean }
defaultState :: State
defaultState = State { open: false }
type MenuProps = { classes :: String }
data Action = Show | Hide
contextMenu :: MenuProps -> Array ReactElement -> ReactElement
contextMenu = createElement contextMenuClass
-- TODO: register callbacks
componentDidMount :: Effect Unit
componentDidMount = pure unit
-- TODO: unregister callbacks
componentWillUnmount :: Effect Unit
componentWillUnmount = pure unit
-- renderMenuItem :: Render State MenuItem Action MenuItem
-- renderMenuItem _ Separator _ _ = li [ className "menu-item-separator" ]
-- renderMenuItem d (MenuItem i) _ _ = wrap outer inner
-- where outer = li [ className "context-menu-item" ]
-- inner = a [ onClick callback, style i.style ] [text i.label]
-- callback _ = d Hide *> i.callback
-- TODO: Aria and accessibility
renderMenu :: Render State MenuProps Action
renderMenu d m s c = pure $ wrap outer $ ul' inner
where outer = div [className (classes s.open m.classes)]
inner = map (\i -> renderMenuItem d i ) c
classes :: Boolean -> String -> String
classes true user = "context-menu context-menu-shown " <> user
classes false user = "context-menu context-menu-hidden " <> user
-- Class
contextMenuClass :: ReactClass { children :: Children, open :: Boolean }
contextMenuClass = component "ContextMenu" createContextMenuClass
createContextMenuClass ::
forall given snapshot spec.
ReactComponentSpec MenuProps State snapshot given spec
=> ReactClassConstructor MenuProps State given
-> ReactClass MenuProps
createContextMenuClass this = pure
{ state: defaultState
, render: renderMenu
, componentDidMount: componentDidMount
, componentWillUnmount: componentWillUnmount
}
src/Gargantext/Types.purs
View file @
2b00da3a
...
...
@@ -9,6 +9,8 @@ import Prim.Row (class Union)
data TermSize = MonoTerm | MultiTerm
data Term = Term String TermList
derive instance eqTermSize :: Eq TermSize
instance showTermSize :: Show TermSize where
...
...
@@ -58,6 +60,12 @@ instance showTermList :: Show TermList where
show StopTerm = "StopTerm"
show CandidateTerm = "CandidateTerm"
-- TODO: Can we replace the show instance above with this?
termListName :: TermList -> String
termListName GraphTerm = "Graph List"
termListName StopTerm = "Stop List"
termListName CandidateTerm = "Candidate List"
readTermList :: String -> Maybe TermList
readTermList "GraphTerm" = Just GraphTerm
readTermList "StopTerm" = Just StopTerm
...
...
src/Gargantext/Utils/Reactil.purs
0 → 100644
View file @
2b00da3a
module Gargantext.Utils.Reactil where
import Prelude
import React (ReactElement)
wrap :: (Array ReactElement -> ReactElement) -> ReactElement -> ReactElement
wrap f e = f [e]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment