API CALLS.md 8.02 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
# Step by Step API calls for a complete user experience

## Description of the use case

User will set as a corpus three articles of "La voix du Nord".
It will applies onto it POS Tagging, Neologisms detection with Neoveille & motifs detection with SDMC.

## I: User set their corpus.

POST /corpora
Quentin David's avatar
Quentin David committed
11

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Request Body:
``` javascript
{
  documents: [
    {
      corpusId: null, // Pas encore créé du coup....
      source: '/article1.txt',
      conlluBuffer: null // TO BE FILLED,maybe later?
    },
    {
      corpusId: null, // Pas encore créé du coup....
      source: '/article2.txt',
      conlluBuffer: null // TO BE FILLED,maybe later?
    },
    {
      corpusId: null, // Pas encore créé du coup....
      source: '/article3.txt',
      conlluBuffer: null // TO BE FILLED,maybe later?
    }
  ],
  createdBy: 'myUserId',
  type: 'public',
  creationDate: '12/10/2020 - 15h44',
  metadata: {
    author: 'La Voix du Nord',
    title: 'Trois articles récents du journal « La voix du Nord »',
    description: "Ces trois articles sont pris au hasard et ont été récupéré grâce à l'outil SOLR de Néoveille. Ils servent comme dummy corpus",
    date: null,
    type: 'Article de journal',
    size: null,
    language: 'fr',
    userMetadata: []
  }
}
```
System will now maybe check all the informations, then try to fill conlluBuffer of each documents by tokenizing the corpus. It will also need to compute the size of the corpus.

49
50
51
52
Informations intéressantes:
- Nombre de mots / tokens
- Taille informatique (du fichier source)

53
54
55
56
From now on, this document (as in a mongo document) will bear the id "corpusId".

## II: User set their pipeline

57
58
59
60
PRETREATMENTS:
La segmentation par phrases et par mots se fera systématiquement lors du conllu buffer, on peut donc enlever ces propriétés de preTreatments.


61
POST /pipelines
Quentin David's avatar
Quentin David committed
62

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Request body:
``` javascript
{
  preTreatments: {
    sentenceSegmentation: false,
    wordSegmentation: true,
    posTagger: true,
    conversionToUTF: false
  },
  // Processes TO BE FILLED
  processes: [
    {
      moduleName: 'Neoveille',
      moduleParameters: [
        {
          name:,
          value:
        }
      ]
    },
    {
      moduleName: 'SDMC',
      moduleParameters: [
        {
          name:,
          value:
        }
      ]
    }
  ],
  creationDate: '12/10/2020 - 15h52',
  description: "Cette chaîne de traitement permet d'identifier les néologismes ainsi que les motifs récurrents."
}
```

This pipeline, created as a document will now bear the id "pipelineId".

## III: System creates a corpus process and starts it

Now that the system registered both the corpus and the pipeline. It can create the corpus process linking those two and start it.

POST /corpusProcesses
Quentin David's avatar
Quentin David committed
105

106
107
108
109
110
111
Request body:
``` javascript
{
  corpusId: corpusId,
  pipelineId: pipelineId,
  userId: 'myUserId',
112
113
  conllu: null, // Will be computed after the POST
  visualAnnotatedDocuments: [], // It will be computed after the pipeline
114
115
116
117
118
119
  outputs: null,
  currentProcessModule: null,
  status: 'Not started yet'
}
```

120
121
122
123
124
On concatène tous les conlluBuffer de chaque document du corpus «corpusId» (GET /corpus/corpusId/...)

PUT /corpusProcesses/corpusProcessId
pour ajouter le conllu concaténer.

125
126
127
128
129
130
### Pre-Treatments executions

Once it is added to the collection, it will fetch the preTreatments in the document of the corresponding pipeline.

``` javascript
preTreatments: {
131
132
    //sentenceSegmentation: false,
    //wordSegmentation: true,
133
    posTagger: true,
134
    codeConversionToUTF: false
135
136
  }
```
137

138
139
140
141
142
wordSegmentation is supposed to be already done as we posted the corpus.

So the system will need to apply the POS Tagger to the corpus.

**TO BE FILLED**
Quentin David's avatar
Quentin David committed
143

144
145
146
147
148
```
I guess it needs to call /modules/treeTagger, 
fetch /corpora/corpusId or /corpusProcess/corpusProcessId and get its conllu which would be the concatenated version.
Then apply the process, then returning a conllu column that we can add to corpusProcess.conllu.
```
Quentin David's avatar
Quentin David committed
149

150
151
152
153
### First module execution

Once it is added to the collection, it will fetch the first process in the list of the corresponding pipelineId and call the module, then update:

154
> POST /modules/Neoveille
Quentin David's avatar
Quentin David committed
155

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
Request body:
``` javascript
{
  // TO BE FILLED
  moduleParameters: [
    {
      name:,
      value:
    }
  ]
}
```

### At the same time: update of corpusProcess

Quentin David's avatar
Quentin David committed
171
172
> PUT /corpusProcess/corpusProcessId

173
174
175
Request body:
``` javascript
{
176
177
  currentProcessingModule: 'Neoveille', // null -> Neoveille
  status: 'Started' // Not started yet -> Started
178
}
Quentin David's avatar
Quentin David committed
179
180
181
182
183
184
```

## IV: Module Processing

The module will need to fetch the conllu.

185
> GET /corpusProcesses/corpusProcessId/conllu
Quentin David's avatar
Quentin David committed
186
187
188
189
190
191
192

Then, given parameters given from the previous paragraph, applies the process to the conllu.

Neoveille will then give back two things:
- one output: the raw list of found neologisms
- one conllu column with

193
> POST /corpusProcess/corpusProcessId/processOutputs
Quentin David's avatar
Quentin David committed
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218

Request body:
``` javascript
{
  newConlluColumn:{
    processId: 'neoveilleProcess',
    columnTitle: 'NEOLOGISMS',
    columnData: '_\n_\nY\n_' //Mockup
  },
  newOutput:{
    processId: 'neoveilleProcess',
    moduleName: 'Neoveille',
    content: {
      title: 'Liste des néologismes',
      description: 'Effectué par Néoveille 2.0, créé par ...., avec ces paramètres:....',
      data: 'schtroumpf\ncoronavirusé\nmacronisme' // ????
    }
  }
}
```

This request adds those two outputs of neoveille process to the collection corpusProcessId.

### When Neoveille is finised...

219
220
(Comment le système sait quand Neoveille finit ?)

Quentin David's avatar
Quentin David committed
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
We can start the next module on the pipeline list.

> POST /modules/SDMC

Request body:
``` javascript
{
  // TO BE FILLED
  moduleParameters: [
    {
      name:,
      value:
    }
  ]
}
```
Then update our corpusProcess

239
> PUT /corpusProcesses/corpusProcessId
Quentin David's avatar
Quentin David committed
240
241
242
243
244
245
246
247
248
249

Request body:
``` javascript
{
  currentProcessingModule: 'SDMC'
}
```

Now, similar to Neoveille, SDMC will need to fetch the conllu, 

250
> GET /corpusProcesses/corpusProcessId/conllu
Quentin David's avatar
Quentin David committed
251
252
253

Process that corpus, then adds its output to the structure

254
> POST /corpusProcesses/corpusProcessId/processOutputs
Quentin David's avatar
Quentin David committed
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287

Request body:
``` javascript
{
  newConlluColumn: {
    processId: 'SDMCProcess',
    columnTitle: 'MOTIFS',
    columnData: '_\n_\n1:3\n_' //Mockup
  }
}
```

## V - Processing annotations

Now that our pipeline is finished, we can update our status

> PUT /corpusProcesses/corpusProcessId

Request body:
``` javascript
{
  currentProcessingModule: null,
  status: 'Processing annotations'
}
```
From now, we can start analysing the conllu and populate AnnotatedDocuments.

First, the system extrates the conllu.

> GET /corpusProcesses/corpusProcessId/conllu

Then it processes it and adds to annotated documents the annotations:

288
289
290
291
> POST /corpusProcesses/corpusProcessId/visualAnnotatedDocument

On coupe le conllu pour chaque document.
On traite pour chaque document toutes ses colonnes
Quentin David's avatar
Quentin David committed
292
293
294
295

Request body:
``` javascript
{
296
  newVisualAnotatedDocument:[
Quentin David's avatar
Quentin David committed
297
298
299
300
301
302
303
304
    {
      documentId: 'article1DocumentId',
      annotations: [
        {
          documentId: 'article1DocumentId',
          processId: 'NeoveilleProcess',
          conlluColumnId: 'conlluNeoveilleId',
          moduleName: 'Neoveille',
305
306
307
308
309
310
311
312
313
314
315
316
          content: {
            title: 'Annotation des Néologismes',
            description: 'Trouvés par Néoveille selon ces paramètres:',
            data: null // ??
          },
          color: null // computed later ?
        },
        {
          documentId: 'article1DocumentId',
          processId: 'SDMCProcess',
          conlluColumnId: 'conlluSDMCId',
          moduleName: 'Neoveille',
Quentin David's avatar
Quentin David committed
317
318
319
320
321
322
323
324
325
          content: {
            title: 'Annotation des Néologismes',
            description: 'Trouvés par Néoveille selon ces paramètres:',
            data: null // ??
          }
        }
      ]
    }
  ]
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
}
```

Il faudrait faire un calcul pour affecter les couleurs pour chaque annotation des documents.

Tout le process est terminé, on peut mettre à jour lestatus de corpusProcess

> PUT /corpusProcesses/corpusProcessId

Request body:
``` javascript
{
  status: 'Finished'
}
```

Et on envoie un mail à l'utilisateur s'il a activé l'option.


( POST /users/myUserId/sendMail )