README.md 6.35 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
# Gargantext Purescript

## About this project

Gargantext is a collaborative web platform for the exploration of sets
of unstructured documents. It combines tools from natural language
processing, text-mining, complex networks analysis and interactive data
visualization to pave the way toward new kinds of interactions with your
digital corpora.

11 12 13 14
You will not find this software very useful without also running or being
granted access to a [backend](https://gitlab.iscpif.fr/gargantext/haskell-gargantext).

This software is free software, developed by the CNRS Complex Systems
15 16
Institute of Paris Île-de-France (ISC-PIF) and its partners.

17 18 19
## Development

### Installing dependencies
20

21 22 23 24 25 26 27 28 29 30 31 32 33
#### Debian

##### Testing Distribution and above
```shell
sudo apt update && sudo apt install nodejs yarn
```

##### Stable Distribution
```shell
curl -sL https://deb.nodesource.com/setup_11.x | sudo bash -
sudo apt update && sudo apt install nodejs
```

34
(For Ubuntu)
35 36 37 38 39 40
```shell
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
```

41 42 43 44 45 46 47 48 49 50 51
To upgrade to latest version (and not current stable) version, you can use
(Use n module from npm in order to upgrade node)

```shell
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo n latest
```


52 53 54 55 56 57 58
### OSX
```shell
brew install node yarn
```

### Installing dependencies

59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
#### Debian

##### Testing Distribution and above
```shell
sudo apt update && sudo apt install nodejs yarn
```

##### Stable Distribution
```shell
curl -sL https://deb.nodesource.com/setup_11.x | sudo bash -
sudo apt update && sudo apt install nodejs
```

```shell
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
```

### OSX
```shell
brew install node yarn
```

### Installing dependencies

85
Before building gargantext, you must install the dependencies. We use
86 87
[yarn](https://yarnpkg.com/en/) for this. They have excellent
[installation instructions](https://yarnpkg.com/en/docs/install).
88

89
Once you have yarn installed, you may install everything else simply:
90

91 92 93
```shell
yarn install && yarn install-ps
```
94

95
You may now build:
96

97 98 99
```shell
yarn build
```
100

101
And run a repl:
102 103 104 105 106

```shell
yarn repl
```

107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
```shell
yarn install && yarn ps-deps
```

### Running a dev server

```shell
yarn dev
```

This will launch a hot-reloading development server with
webpack-dev-server.  Visit [localhost:9000](http://localhost:9000/) to
see the result when the output shows a line like this:

```
ℹ 「wdm」: Compiled successfully.
```

#### Purescript IDE integration

A `purs ide` connection will be available on port 9002 while the
development server is running.

A guide to getting set up with the IDE integration is beyond the scope
of this document.

#### Source maps

Currently broken. Someone please fix them.

### Getting a purescript repl

```shell
yarn repl
```

### Building for production

```shell
yarn build
```

Note that a production build takes a little while.

### How do I?

#### Change which backend to connect to?

Edit `Config.purs`. Find the function `endConfig'` just after the
imports and edit `back`. The definitions are not far below, just after
the definitions of the various `front` options.

Example (using `demo.gargantext.org` as backend):

```
endConfig' :: ApiVersion -> EndConfig
endConfig' v = { front : frontRelative
               , back  : backDemo v  }
```

### Contributor notes
168 169

Please follow CONTRIBUTING.md
170

171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
### How do I?

#### Add a javascript dependency?

Add it to `package.json`, under `dependencies` if it is needed at
runtime or `devDependencies` if it is not.

#### Add a purescript dependency?

Add it to `psc-package.json` without the `purescript-` prefix.

If is not in the package set, you will need to read the next section.

#### Add a custom or override package to the local package set?

You need to add an entry to the relevant map in
`packages.dhall`. There are comments in the file explaining how it
works. It's written in dhall, so you can use comments and such.

190 191 192 193 194 195
You will then need to rebuild the package set:

```shell
yarn rebuild-set
```

196 197 198
#### Upgrade the base package set local is based on to latest?

```shell
199
yarn rebase-set && yarn rebuild-set
200 201 202
```

## Theory Introduction
203 204

Making sense of out text isn't actually that hard, but it does require
205
a little background knowledge to understand.
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232

### 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).

233 234
<!-- TODO: Discuss punctuation -->

235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
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`
257
trigram/3-gram
258 259 260 261 262 263 264 265
: 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 -->