From bb2ba5336f1634ae6629350481e4136cc887e438 Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Tue, 11 Dec 2018 20:11:24 +0100 Subject: [PATCH 1/8] Remove duplicate paragraph in Index Fixes https://gitlab.cs.fau.de/bi40resu/vue-cdbp/issues/15 --- src/components/Index.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Index.vue b/src/components/Index.vue index 6855f13..3ca1d47 100644 --- a/src/components/Index.vue +++ b/src/components/Index.vue @@ -15,7 +15,6 @@ -

Ce projet des pétitions des bagnards et leurs proches, commencé en février 2016, réunit des textes des personnes dites ‘peu-lettrés’ réalisés entre 1854 et 1896. Ces correspondances font preuve d’un écartement de la norme du français standard dans maints domaines: relations graphie-phonie, morphosyntaxe, lexique ou traditions discursives.

Le corpus, composé de textes – jusqu’ici – inconnus de la recherche linguistique, provient des Archives Nationales d’outre-mer à Aix-en-Provence et comprend plus de 300 documents. Dans ces lettres, les auteurs écrivent au Ministre de la Marine et des Colonies, au Préfet ou bien au Directeur afin de leur demander leur aide. Les suppliques englobent grosso modo cinq thèmes:

-- GitLab From 91f9c55f601876418abaed824229561e74ea53e0 Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Tue, 11 Dec 2018 20:26:15 +0100 Subject: [PATCH 2/8] Add some description for search features --- src/components/Features.vue | 5 +++++ src/components/Search.vue | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/components/Features.vue b/src/components/Features.vue index 58b80e5..6815e82 100644 --- a/src/components/Features.vue +++ b/src/components/Features.vue @@ -5,6 +5,11 @@

{{header}}

+ +

Features are annotated properties of each letter. They have a category, a type and a subtype. These properties are hierarchical.

+

With the feature search you can quickly lookup the annotated features within all categories. The search supports regular expressions and can be restricted to a single letter.

+
+ {{header}} + +

With the search you can search for regular expressions with in all tags and corresponding contents.

+
+ -- GitLab From 557bec81714d1551c436f13a5bcb3adb03b557c1 Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Tue, 11 Dec 2018 20:43:20 +0100 Subject: [PATCH 3/8] Handle Tags Fixes https://gitlab.cs.fau.de/bi40resu/vue-cdbp/issues/17 --- src/components/Letter.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/Letter.vue b/src/components/Letter.vue index 06f9db5..a10a662 100644 --- a/src/components/Letter.vue +++ b/src/components/Letter.vue @@ -43,6 +43,9 @@
  • {{value._attributes.no }}: {{ formatText(value._text) }} +
    + {{elem._attributes.text}} +
-- GitLab From e89d8292db281baebc00ad7447b4593afcb6a6e3 Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Wed, 12 Dec 2018 17:14:21 +0100 Subject: [PATCH 4/8] Add feature glossary API endpoint --- app.js | 10 ++++++++++ lib.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/app.js b/app.js index 46a8a55..affc04c 100755 --- a/app.js +++ b/app.js @@ -177,6 +177,11 @@ app.get('/api/search/:letter?', function (req, res, next) { res.send(data) }) +app.get('/api/features/', function (req, res) { + // Feature Glossary + res.send(lib.glossary(loadDocuments(DIR))) +}) + app.get('/api/features/:letter?', function (req, res) { // Feature Search Endpoint with query parameters // @@ -213,6 +218,7 @@ app.get('/api/features/:letter?', function (req, res) { res.send(data.sort(lib.compare)) }) + app.get('/api/letters/:letter?', function (req, res) { // Document Endpoint with optional Document name // Lists either all or one given document @@ -242,6 +248,10 @@ app.get('/api/metadata/reload', function (req, res) { // Loading all documents to cache loadDocumentsToCache(DIR) +// Loading all documents to cache +// loadGlossaryToCache(DIR) + + // Where the magic happens app.listen(PORT, function () { console.log('> Listening at http://localhost:' + PORT) diff --git a/lib.js b/lib.js index 8b7d28e..9b06dd1 100755 --- a/lib.js +++ b/lib.js @@ -143,6 +143,59 @@ function searchFeaturesInDocument (document, query) { return document } +function featureToString (feature) { + /* + * Turn into feature object into category>type>subtype String + */ + + let category = feature.category + let type = feature.type + let subtype = feature.subtype + + let ret = '' + + if (category !== undefined) { + ret = ret.concat(category) + } + if (type !== undefined) { + ret = ret.concat(' > ', type) + } + if (subtype !== undefined) { + ret = ret.concat(' > ', subtype) + } + + return ret +} + +function featureGlossary (objs) { + /* + * Turn list of documents objects into a glossary set + */ + + let featureList = [] + + for (let document of objs) { + try { + let documentFeatures = findKeyRecursive(document, 'feature') + for (let feature of documentFeatures) { + delete feature._attributes['ref'] + featureList.push(feature._attributes) + } + } catch (err) { + console.log(arguments.callee) // eslint-disable-line no-caller + console.log('>> Error while getting features from' + document.name) + console.log(err) + } + } + + let featureArray = [] + for (let feat of featureList) { + featureArray.push(featureToString(feat)) + } + + return Array.from(new Set(featureArray)) +} + function metadataTable (objs) { /* * Turn list of documents objects into metadata table format @@ -189,6 +242,9 @@ module.exports = { table: function (objs) { return metadataTable(objs) }, + glossary: function (objs) { + return featureGlossary(objs) + }, compare: function (a, b) { if (a.hits > b.hits) { return -1 } if (a.hits < b.hits) { return 1 } -- GitLab From 302932aa7ae03388415b1d162d710349d19fee90 Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Thu, 13 Dec 2018 10:04:03 +0100 Subject: [PATCH 5/8] Add Glossary to frontend --- src/components/Features.vue | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/components/Features.vue b/src/components/Features.vue index 6815e82..a1ea3e8 100644 --- a/src/components/Features.vue +++ b/src/components/Features.vue @@ -10,6 +10,23 @@

With the feature search you can quickly lookup the annotated features within all categories. The search supports regular expressions and can be restricted to a single letter.

+ + + +
Glossary
+ + +
    +
  • + {{feat}} +
  • +
+
+
+
+
+
+ Date: Tue, 18 Dec 2018 13:22:29 +0100 Subject: [PATCH 6/8] Add autocomplete and fix some bugs in feature search --- app.js | 14 +++++-- lib.js | 23 +++++++++-- src/components/Features.vue | 76 +++++++++++++++++-------------------- 3 files changed, 64 insertions(+), 49 deletions(-) diff --git a/app.js b/app.js index affc04c..f51584a 100755 --- a/app.js +++ b/app.js @@ -177,7 +177,7 @@ app.get('/api/search/:letter?', function (req, res, next) { res.send(data) }) -app.get('/api/features/', function (req, res) { +app.get('/api/glossary/features', function (req, res) { // Feature Glossary res.send(lib.glossary(loadDocuments(DIR))) }) @@ -185,9 +185,10 @@ app.get('/api/features/', function (req, res) { app.get('/api/features/:letter?', function (req, res) { // Feature Search Endpoint with query parameters // - if (!req.query.category){ - res.send({}) - return next('No Query provided') + + if (!req.query) { + res.status(400).send('No Query provided') + return } let query = { @@ -207,6 +208,11 @@ app.get('/api/features/:letter?', function (req, res) { for (let doc of documents) { let obj = loadDocument(doc) + + if (!obj) { + continue + } + if (obj.valid) { let results = lib.features(obj, query) if (results !== null) { diff --git a/lib.js b/lib.js index 9b06dd1..a77e493 100755 --- a/lib.js +++ b/lib.js @@ -188,12 +188,29 @@ function featureGlossary (objs) { } } - let featureArray = [] + let categories = [] + let types = [] + let subtypes = [] + for (let feat of featureList) { - featureArray.push(featureToString(feat)) + if (feat.category !== undefined) { + categories.push(feat.category) + } + if (feat.type !== undefined) { + types.push(feat.type) + } + if (feat.subtype !== undefined) { + subtypes.push(feat.subtype) + } } - return Array.from(new Set(featureArray)) + let ret = { + categories: Array.from(new Set(categories)), + types: Array.from(new Set(types)), + subtypes: Array.from(new Set(subtypes)) + } + + return ret } function metadataTable (objs) { diff --git a/src/components/Features.vue b/src/components/Features.vue index a1ea3e8..5e0e60f 100644 --- a/src/components/Features.vue +++ b/src/components/Features.vue @@ -8,23 +8,7 @@

Features are annotated properties of each letter. They have a category, a type and a subtype. These properties are hierarchical.

With the feature search you can quickly lookup the annotated features within all categories. The search supports regular expressions and can be restricted to a single letter.

-
- - - -
Glossary
- - -
    -
  • - {{feat}} -
  • -
-
-
-
-
@@ -34,34 +18,37 @@ v-model="selected" label="Select" single-line - bottom prepend-icon="local_post_office" >
- - + :items="feature_categories_glossary" + label="Category" + @keyup.enter.native="validate" + > + - - + :items="feature_types_glossary" + label="Types" + @keyup.enter.native="validate" + > + - - + :items="feature_subtypes_glossary" + label="Subtypes" + @keyup.enter.native="validate" + > + @@ -108,7 +95,9 @@ export default { header: 'Feature Search', invalid: false, searching: false, - feature_glossary: [], + feature_categories_glossary: [], + feature_types_glossary: [], + feature_subtypes_glossary: [], feature_category: '', feature_type: '', feature_subtype: '', @@ -116,25 +105,24 @@ export default { letters: [ { text: 'All' } ], - selected: { text: 'All' } + selected: 'All' } }, methods: { clear () { // Clears the search input fields - this.feature_category = null - this.feature_type = null - this.feature_subtype = null + this.feature_category = '' + this.feature_type = '' + this.feature_subtype = '' }, find () { // Call feature search API with parameters this.searching = true let url = 'http://localhost:3000/api/features/' - // TODO: this is a bit silly // Adding the lettername to the API endpoint - if (this.selected.text !== 'All') { - url = url + this.selected.text.replace(/ /g, '_') + '/' + if (this.selected !== 'All') { + url = url + this.selected } let params = { @@ -173,14 +161,18 @@ export default { }, created () { // Get feature glossary - this.$http.get('http://localhost:3000/api/features').then(function (data) { - this.feature_glossary = data.body + this.$http.get('http://localhost:3000/api/glossary/features').then(function (data) { + this.feature_categories_glossary = data.body.categories + this.feature_types_glossary = data.body.types + this.feature_subtypes_glossary = data.body.subtypes }) // Create list of all letters this.$http.get('http://localhost:3000/api/metadata/table').then(function (data) { for (let letter of data.body) { - this.letters.push({text: letter.name}) + if (letter.valid) { + this.letters.push({text: letter.title}) + } } }) } -- GitLab From ca7e6522bd1328a611144234b2884542f87b5ceb Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Tue, 18 Dec 2018 13:50:52 +0100 Subject: [PATCH 7/8] Add display of note tags in Letter component --- src/components/Letter.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Letter.vue b/src/components/Letter.vue index a10a662..26105d1 100644 --- a/src/components/Letter.vue +++ b/src/components/Letter.vue @@ -44,7 +44,10 @@
  • {{value._attributes.no }}: {{ formatText(value._text) }}
    - {{elem._attributes.text}} +
    + {{note._text}}: {{note._attributes.text}} + {{note.text}} +
  • @@ -135,6 +138,8 @@ export default { // Do this last for progress bar this.letter = data.body.TEI + + console.log(data.body.TEI.text.body.l[0].note) }) } } -- GitLab From 04c5bb08f3af67bde4639942abceaaaaeb86b8fa Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Tue, 18 Dec 2018 14:52:39 +0100 Subject: [PATCH 8/8] Change frontend to french --- src/App.vue | 8 ++++---- src/components/Features.vue | 25 ++++++++++++++++--------- src/components/Letter.vue | 14 +++++++------- src/components/Letters.vue | 2 +- src/components/Metadata.vue | 4 ++-- src/components/Result.vue | 6 +++--- src/components/Search.vue | 32 ++++++++++---------------------- 7 files changed, 43 insertions(+), 48 deletions(-) diff --git a/src/App.vue b/src/App.vue index 885fc0b..d165861 100644 --- a/src/App.vue +++ b/src/App.vue @@ -61,19 +61,19 @@ icon: 'home' }, { href: '/letters', - title: 'Letters', + title: 'Lettres', icon: 'mail_outline' }, { href: '/metadata', - title: 'Metadata', + title: 'Métadonnées', icon: 'apps' }, { href: '/features', - title: 'Features', + title: 'Caractéristiques', icon: 'menu' }, { href: '/search', - title: 'Search', + title: 'Recherche', icon: 'search' }] } diff --git a/src/components/Features.vue b/src/components/Features.vue index 5e0e60f..c33d5cd 100644 --- a/src/components/Features.vue +++ b/src/components/Features.vue @@ -6,8 +6,15 @@ -

    Features are annotated properties of each letter. They have a category, a type and a subtype. These properties are hierarchical.

    -

    With the feature search you can quickly lookup the annotated features within all categories. The search supports regular expressions and can be restricted to a single letter.

    +

    + les caractéristiques sont les propriétés de chaque lettre. Elles disposent d'une catégorie, d'un type et d'un sous-type organisés de manière hierarchique. +

    + +

    + La 'Recherche de caractéristique' facilite la recherche rapipde de toute sorte de traits propres aux lettres. + + La 'Recherche de caractéristique' soutient également les expressions régulières et peut être restreinte à une seule lettre. +

    @@ -53,8 +60,8 @@ - Search - Clear + Rechercher + Supprimer @@ -73,7 +80,7 @@ - Results: {{results.length}} letter(s) - {{countedHits}} hit(s) + Lettre(s): {{results.length}} dont résultat(s): {{countedHits}} @@ -92,7 +99,7 @@ export default { data () { // Search for Features in Letters return { - header: 'Feature Search', + header: 'Recherche de caractéristiques', invalid: false, searching: false, feature_categories_glossary: [], @@ -103,9 +110,9 @@ export default { feature_subtype: '', results: null, letters: [ - { text: 'All' } + { text: 'Toutes' } ], - selected: 'All' + selected: 'Toutes' } }, methods: { @@ -121,7 +128,7 @@ export default { let url = 'http://localhost:3000/api/features/' // Adding the lettername to the API endpoint - if (this.selected !== 'All') { + if (this.selected !== 'Toutes') { url = url + this.selected } diff --git a/src/components/Letter.vue b/src/components/Letter.vue index 26105d1..2208f4d 100644 --- a/src/components/Letter.vue +++ b/src/components/Letter.vue @@ -39,7 +39,7 @@ - +
    • {{value._attributes.no }}: {{ formatText(value._text) }} @@ -129,12 +129,12 @@ export default { } // So we can iterate in the template - this.features.push({text: 'Material and Visuals', root: data.body.TEI.teiHeader.xenoData.paratext}) - this.features.push({text: 'Graphemics', root: data.body.TEI.teiHeader.xenoData.sprachliche_ebene.graphische_charaktersitika}) - this.features.push({text: 'Lexical', root: data.body.TEI.teiHeader.xenoData.sprachliche_ebene.lexikalische_charaktersitika}) - this.features.push({text: 'Morphosyntactics', root: data.body.TEI.teiHeader.xenoData.sprachliche_ebene.morphosyntaktische_charakterisitka}) - this.features.push({text: 'Pragmatics', root: data.body.TEI.teiHeader.xenoData.sprachliche_ebene.textstrukturelle_pragmatische_charakterisitka}) - this.features.push({text: 'Discourse', root: data.body.TEI.teiHeader.xenoData.sprachliche_ebene.diskurstraditionelle_ebene}) + this.features.push({text: 'caractéristiques visuelles', root: data.body.TEI.teiHeader.xenoData.paratext}) + this.features.push({text: 'caractéristiques graphiques', root: data.body.TEI.teiHeader.xenoData.sprachliche_ebene.graphische_charaktersitika}) + this.features.push({text: 'caractéristiques lexicales', root: data.body.TEI.teiHeader.xenoData.sprachliche_ebene.lexikalische_charaktersitika}) + this.features.push({text: 'caractéristiques morphosyntaxiques', root: data.body.TEI.teiHeader.xenoData.sprachliche_ebene.morphosyntaktische_charakterisitka}) + this.features.push({text: 'caractéristiques pragmatiques', root: data.body.TEI.teiHeader.xenoData.sprachliche_ebene.textstrukturelle_pragmatische_charakterisitka}) + this.features.push({text: 'caractéristiques de tradition discursive', root: data.body.TEI.teiHeader.xenoData.sprachliche_ebene.diskurstraditionelle_ebene}) // Do this last for progress bar this.letter = data.body.TEI diff --git a/src/components/Letters.vue b/src/components/Letters.vue index 7302bc1..7c5f0cc 100644 --- a/src/components/Letters.vue +++ b/src/components/Letters.vue @@ -56,7 +56,7 @@ export default { name: 'Letters', data () { return { - header: 'Letters', + header: 'Lettres', letters: null, reloading: false, timeout: 1000, diff --git a/src/components/Metadata.vue b/src/components/Metadata.vue index 2975c39..3e16e8b 100644 --- a/src/components/Metadata.vue +++ b/src/components/Metadata.vue @@ -9,7 +9,7 @@ v.length <= 25 || 'Input too long!', tmp: '', search: '', diff --git a/src/components/Result.vue b/src/components/Result.vue index 534ebba..582f90f 100644 --- a/src/components/Result.vue +++ b/src/components/Result.vue @@ -4,7 +4,7 @@ {{letter.name}}{{letter.collection}} {{letter.hits}} - Hits + résultat(s) @@ -13,7 +13,7 @@ {{hit._text}} - Line: {{(hit._attributes.no)}} + Ligne: {{(hit._attributes.no)}} Category: {{(hit._attributes.category)}} , Type: {{(hit._attributes.type)}} , Subtype: {{(hit._attributes.subtype)}} @@ -30,7 +30,7 @@
    - View + Montrer
    diff --git a/src/components/Search.vue b/src/components/Search.vue index d2d8eea..ff799ac 100644 --- a/src/components/Search.vue +++ b/src/components/Search.vue @@ -6,31 +6,19 @@
    -

    With the search you can search for regular expressions with in all tags and corresponding contents.

    -
    +

    Ci-dessous, il est possible de rechercher toute sorte de tag et de co-occurrence graphique à l'aide des expressions régulières.

    - - - - -
    Toggle Syntax Help
    - - -

    Content in an element: element:content (Regular Expressions are supported)

    -

    If no element is provided, the text will be searched.

    - - -
    -
    -
    -
    +
    Syntaxe
    +

    Rechercher contenu dans un tag: tag:contenu

    + +

    Quand le tag n'est pas spécifié, le texte sert de base de recherche.

    - Search - Clear + Rechercher + Supprimer @@ -63,7 +51,7 @@ - Results: {{results.length}} letter(s) + Résultats: {{results.length}} lettre(s) @@ -83,7 +71,7 @@ export default { name: 'Search', data () { return { - header: 'Search', + header: 'Rechercher', invalid: false, search: '', pattern: '^([a-z]+):(.+)', -- GitLab