diff --git a/frontend/.gitignore b/frontend/.gitignore index 358c028..08d4b91 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -22,4 +22,3 @@ pnpm-debug.log* *.sln *.sw? -!lib/ diff --git a/frontend/src/components/Common/TextSelector.vue b/frontend/src/components/Common/TextSelector.vue index 3b77cd0..6607440 100644 --- a/frontend/src/components/Common/TextSelector.vue +++ b/frontend/src/components/Common/TextSelector.vue @@ -195,7 +195,7 @@ export default { this.options = filteredOptions; }, async handleTextDeleteClick(textId) { - await axios.delete(`/api/delete_text/${textId}`); + await axios.delete(`/swegram/beta/api/delete_text/${textId}`); this.textIDs = this.textIDs.filter((text) => text[0] !== textId); this.chosenTextIds = this.chosenTextIds.filter((text) => text !== textId); this.metaData = this.metaData.filter((meta) => meta[2] !== textId); @@ -214,7 +214,7 @@ export default { localStorage.setItem('metadata', JSON.stringify({ en: {}, sv: {} })); } axios - .put('/api/update_texts/', { + .put('/swegram/beta/api/update_texts/', { texts: JSON.parse(localStorage.textList)[lang], metadata: JSON.parse(localStorage.metadata)[lang], }) @@ -255,7 +255,7 @@ export default { .filter((textId) => textId[0] !== -10000) .map((i) => [i[0], this.chosenTextIds.includes(i[0])]); axios - .put('/api/update_states', { + .put('/swegram/beta/api/update_states', { textStates: Object.fromEntries(entries), texts: JSON.parse(localStorage.textList)[lang], }); diff --git a/frontend/src/components/DownloadPage.vue b/frontend/src/components/DownloadPage.vue index fe4ac44..d052e12 100644 --- a/frontend/src/components/DownloadPage.vue +++ b/frontend/src/components/DownloadPage.vue @@ -211,7 +211,7 @@ export default { } if (!this.downloadDisabled && this.tooltipDisabled) { if (this.downloadType.includes('texts')) { - const textDownloadURL = '/download_text/'; + const textDownloadURL = '/swegram/beta/download_text/'; axios({ method: 'post', data: { @@ -231,7 +231,7 @@ export default { link.click(); }); } if (this.downloadType.includes('statistics')) { - const statsDownloadURL = '/download_stats/'; + const statsDownloadURL = '/swegram/beta/download_stats/'; axios({ method: 'post', data: { diff --git a/frontend/src/components/Statistics/SnippetFrequencyPage.vue b/frontend/src/components/Statistics/SnippetFrequencyPage.vue index 4b3ac5e..954166a 100644 --- a/frontend/src/components/Statistics/SnippetFrequencyPage.vue +++ b/frontend/src/components/Statistics/SnippetFrequencyPage.vue @@ -162,7 +162,7 @@ export default { localStorage.setItem('textList', JSON.stringify({})); } const lang = this.$route.params.toolVersion; - const dataURL = `/${this.$props.category}/${this.$props.tagset}`; + const dataURL = `/swegram/beta/${this.$props.category}/${this.$props.tagset}`; axios .post(dataURL, { texts: JSON.parse(localStorage.textList), diff --git a/frontend/src/components/Statistics/SnippetLengthPage.vue b/frontend/src/components/Statistics/SnippetLengthPage.vue index 3660c04..6380061 100644 --- a/frontend/src/components/Statistics/SnippetLengthPage.vue +++ b/frontend/src/components/Statistics/SnippetLengthPage.vue @@ -136,7 +136,7 @@ export default { } const lang = this.$route.params.toolVersion; axios - .post(`/${this.$props.category}/${this.$props.tagset}/`, { + .post(`/swegram/beta/${this.$props.category}/${this.$props.tagset}/`, { texts: JSON.parse(localStorage.textList), length: true, lang, diff --git a/frontend/src/components/Statistics/SnippetStatisticsPanel.vue b/frontend/src/components/Statistics/SnippetStatisticsPanel.vue index 95946bd..732e8f0 100644 --- a/frontend/src/components/Statistics/SnippetStatisticsPanel.vue +++ b/frontend/src/components/Statistics/SnippetStatisticsPanel.vue @@ -122,7 +122,7 @@ export default { localStorage.setItem('textList', JSON.stringify({})); } const lang = this.$route.params.toolVersion; - const featsURL = `/features/${this.$props.level}/${this.currentPage}`; + const featsURL = `/swegram/beta/features/${this.$props.level}/${this.currentPage}`; axios .post(featsURL, { diff --git a/frontend/src/components/Statistics/SnippetsList.vue b/frontend/src/components/Statistics/SnippetsList.vue index 29f2130..96e130f 100644 --- a/frontend/src/components/Statistics/SnippetsList.vue +++ b/frontend/src/components/Statistics/SnippetsList.vue @@ -150,7 +150,7 @@ export default { localStorage.setItem('textList', JSON.stringify({})); } const lang = this.$route.params.toolVersion; - const overviewURL = `/overview/${this.$props.level}`; + const overviewURL = `/swegram/beta/overview/${this.$props.level}`; axios .post(overviewURL, { texts: JSON.parse(localStorage.textList), diff --git a/frontend/src/components/Statistics/StatisticsPage.vue b/frontend/src/components/Statistics/StatisticsPage.vue index be616fd..a56646b 100644 --- a/frontend/src/components/Statistics/StatisticsPage.vue +++ b/frontend/src/components/Statistics/StatisticsPage.vue @@ -18,34 +18,6 @@ type="border-card" @tab-click="handleShowTagset" > - - - - - - - - + + + + + + + + @@ -178,7 +178,7 @@ export default { localStorage.setItem('textList', JSON.stringify({})); } const lang = this.$route.params.toolVersion; - const baseURL = '/get_text_stats/'; + const baseURL = '/swegram/beta/get_text_stats/'; axios .post(baseURL, { textList: JSON.parse(localStorage.textList), diff --git a/frontend/src/components/TopNav/TopNavbar.vue b/frontend/src/components/TopNav/TopNavbar.vue index 3779abe..2ba3aea 100644 --- a/frontend/src/components/TopNav/TopNavbar.vue +++ b/frontend/src/components/TopNav/TopNavbar.vue @@ -8,6 +8,7 @@ :default-active="activeLink" background-color="#F4DE48" active-text-color="black" + text-color="black" mode="horizontal" router > @@ -17,12 +18,12 @@ {{ $t('topNavbar.addText') }} - - {{ $t('topNavbar.visualize') }} - {{ $t('topNavbar.statistics') }} + + {{ $t('topNavbar.visualize') }} + Export @@ -42,6 +43,7 @@ :default-active="activeLink" background-color="#F2575F" active-text-color="black" + text-color="black" mode="horizontal" router > @@ -51,12 +53,12 @@ {{ $t('topNavbar.addText') }} - - {{ $t('topNavbar.visualize') }} - {{ $t('topNavbar.statistics') }} + + {{ $t('topNavbar.visualize') }} + Export diff --git a/frontend/src/components/Upload/UploadForm.vue b/frontend/src/components/Upload/UploadForm.vue index 5f21d0d..f23bc84 100644 --- a/frontend/src/components/Upload/UploadForm.vue +++ b/frontend/src/components/Upload/UploadForm.vue @@ -196,7 +196,7 @@ export default { message: this.$t('uploadForm.uploadSuccessMsg'), type: 'success', }); - this.$router.push(`/${this.$route.params.toolVersion}/visualize`); + this.$router.push(`/${this.$route.params.toolVersion}/visualize/`); this.$emit('uploaded'); } }, @@ -256,10 +256,11 @@ export default { uploadURL() { // const tokenization = this.formData.checkTokenize ? 'tokenized' : 'untokenized'; if (this.formData.annotated) { - return `/upload/${this.$route.params.toolVersion}`; // This uploads annotated file, lang needed to be modified + // return `/swegram/beta/api/upload_text/${this.$route.params.toolVersion}`; + return `/swegram/beta/upload/${this.$route.params.toolVersion}`; // This uploads annotated file, lang needed to be modified } - return `/upload_annotate/${this.$route.params.toolVersion}`; // This actually means upload AND annotate - // return '/upload_annotate/'; // This actually means upload AND annotate + return `/swegram/beta/upload_annotate/${this.$route.params.toolVersion}`; // This actually means upload AND annotate + // return '/swegram/beta/upload_annotate/'; // This actually means upload AND annotate }, }, }; diff --git a/frontend/src/components/Upload/UploadPage.vue b/frontend/src/components/Upload/UploadPage.vue index fec792c..db9f221 100644 --- a/frontend/src/components/Upload/UploadPage.vue +++ b/frontend/src/components/Upload/UploadPage.vue @@ -7,15 +7,16 @@ v-show="!showTextForm" id="upload_annotate_main" > - {{ $tc('uploadPage.uploadMessage1', 0) }} -
+ {{ $t('uploadPage.uploadMessage1') }} + +

{{ $tc('uploadPage.uploadMessage2', 0) }} {{ $tc('uploadPage.uploadMessage2', 1) }} {{ $tc('uploadPage.uploadMessage2', 2) }} diff --git a/frontend/src/components/Visualize/VisualizePage.vue b/frontend/src/components/Visualize/VisualizePage.vue index d881806..5bff3f7 100644 --- a/frontend/src/components/Visualize/VisualizePage.vue +++ b/frontend/src/components/Visualize/VisualizePage.vue @@ -66,7 +66,7 @@ export default { checkCurrentTextParsed(newValue) { if (newValue !== '0' && newValue) { axios - .get(`/api/get_text/${newValue}`) + .get(`/swegram/beta/api/get_text/${newValue}`) .then((response) => { this.currentTextParsed = JSON.parse(response.data)[0].fields.parsed; }) @@ -93,7 +93,7 @@ export default { if (this.currentText !== null && this.currentText !== '0') { this.tokens = []; axios - .get(`/visualise_text/${this.currentText}/${this.currentPage}/`) + .get(`/swegram/beta/visualise_text/${this.currentText}/${this.currentPage}/`) .then((response) => { const { data } = response; this.currentSentences = data.current_sentences; diff --git a/frontend/src/i18n/langs/en.js b/frontend/src/i18n/langs/en.js index f3dc888..1690a89 100644 --- a/frontend/src/i18n/langs/en.js +++ b/frontend/src/i18n/langs/en.js @@ -251,7 +251,7 @@ const en = { }, uploadPage: { annotateNewText: 'Annotate a new text', - uploadMessage1: 'In order to annotate a new text, you can either | upload one or multiple (texts in format .doc, docx, .odt or .rtf, which are automatically converted into plain text), or | paste in a text.', + uploadMessage1: 'In order to annotate a new text, you can upload a plain text, or paste in a text.', uploadMessage2: 'For more information how metadata is handled, see | help | in menu.', textUploadButton: 'Upload a file', textPasteButton: 'Paste in a text', @@ -272,7 +272,7 @@ const en = { uploadFailedMsg: 'An error occured\n{0}', uploadErrNonText: 'Please upload text files only', uploadErrFileTooBig: 'Please upload a file less than 100MB', - beforeUploadWarning: 'Upload a big file could take up to several hours, are you sure you want to continue?', + beforeUploadWarning: 'Uploading and processing a big file can take time.', }, ...elementEN, }; diff --git a/frontend/src/i18n/langs/sv.js b/frontend/src/i18n/langs/sv.js index 4feea28..233dd8d 100644 --- a/frontend/src/i18n/langs/sv.js +++ b/frontend/src/i18n/langs/sv.js @@ -250,7 +250,7 @@ const sv = { }, uploadPage: { annotateNewText: 'Annotera ny text', - uploadMessage1: 'För att annotera en ny text kan du antingen | ladda upp en eller flera textfiler (texter i format .doc, docx, .odt och .rtf konverteras automatiskt till ren text), eller | klistra in en text.', + uploadMessage1: 'För att annotera en ny text kan du ladda upp en klartext, eller klistra in en text.', uploadMessage2: 'För information om hantering av metadata, se | hjälp | i menyn.', textUploadButton: 'Ladda upp textfil', textPasteButton: 'Klistra in text', @@ -271,7 +271,7 @@ const sv = { uploadFailedMsg: 'An error occured\n{0}', uploadErrNonText: 'Please upload text files only', uploadErrFileTooBig: 'Please upload a file less than 100MB', - beforeUploadWarning: 'Upload a big file could take up to several hours, are you sure you want to continue?', + beforeUploadWarning: 'Upploading och parsering en stor fil kan ta lång tid', }, ...elementSV, }; diff --git a/frontend/vue.config.js b/frontend/vue.config.js index aec1ae9..e8b14e2 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -2,7 +2,9 @@ const BundleTracker = require('webpack-bundle-tracker'); module.exports = { // on Windows you might want to set publicPath: "http://127.0.0.1:8080/" - publicPath: 'http://0.0.0.0:8000/static/', + // ublicPath: 'http://0.0.0.0:8000/static/', + publicPath: 'http://0.0.0.0:8080/', + // publicPath: 'https://kasus.lingfil.uu.se/swegrambetastatic/', outputDir: './dist/', @@ -26,7 +28,7 @@ module.exports = { // config.optimization.splitChunks(false); config.optimization.splitChunks(false); - config.resolve.alias.set('__STATIC__', 'static'); + config.resolve.alias.set('__STATIC__', 'swegrambetastatic'); config.devServer // the first 3 lines of the following code have been added to the configuration diff --git a/frontend/webpack-stats.json b/frontend/webpack-stats.json index 46c4a2a..c7067e8 100644 --- a/frontend/webpack-stats.json +++ b/frontend/webpack-stats.json @@ -3,43 +3,43 @@ "assets": { "fonts/element-icons.535877f5.woff": { "name": "fonts/element-icons.535877f5.woff", - "path": "/home/rruan1/swegram/frontend/dist/fonts/element-icons.535877f5.woff", - "publicPath": "http://0.0.0.0:8000/static/fonts/element-icons.535877f5.woff" + "path": "/home/rruan1/swegram_dev/swegram/frontend/dist/fonts/element-icons.535877f5.woff", + "publicPath": "http://0.0.0.0:8080/fonts/element-icons.535877f5.woff" }, "fonts/element-icons.732389de.ttf": { "name": "fonts/element-icons.732389de.ttf", - "path": "/home/rruan1/swegram/frontend/dist/fonts/element-icons.732389de.ttf", - "publicPath": "http://0.0.0.0:8000/static/fonts/element-icons.732389de.ttf" - }, - "img/swe-clarin-logo.6a0e99ef.png": { - "name": "img/swe-clarin-logo.6a0e99ef.png", - "path": "/home/rruan1/swegram/frontend/dist/img/swe-clarin-logo.6a0e99ef.png", - "publicPath": "http://0.0.0.0:8000/static/img/swe-clarin-logo.6a0e99ef.png" + "path": "/home/rruan1/swegram_dev/swegram/frontend/dist/fonts/element-icons.732389de.ttf", + "publicPath": "http://0.0.0.0:8080/fonts/element-icons.732389de.ttf" }, "img/UU_logo_sv_84_transparent.a0393307.png": { "name": "img/UU_logo_sv_84_transparent.a0393307.png", - "path": "/home/rruan1/swegram/frontend/dist/img/UU_logo_sv_84_transparent.a0393307.png", - "publicPath": "http://0.0.0.0:8000/static/img/UU_logo_sv_84_transparent.a0393307.png" + "path": "/home/rruan1/swegram_dev/swegram/frontend/dist/img/UU_logo_sv_84_transparent.a0393307.png", + "publicPath": "http://0.0.0.0:8080/img/UU_logo_sv_84_transparent.a0393307.png" + }, + "img/swe-clarin-logo.6a0e99ef.png": { + "name": "img/swe-clarin-logo.6a0e99ef.png", + "path": "/home/rruan1/swegram_dev/swegram/frontend/dist/img/swe-clarin-logo.6a0e99ef.png", + "publicPath": "http://0.0.0.0:8080/img/swe-clarin-logo.6a0e99ef.png" }, "bundle.css": { "name": "bundle.css", - "path": "/home/rruan1/swegram/frontend/dist/bundle.css", - "publicPath": "http://0.0.0.0:8000/static/bundle.css" + "path": "/home/rruan1/swegram_dev/swegram/frontend/dist/bundle.css", + "publicPath": "http://0.0.0.0:8080/bundle.css" }, "bundle.js": { "name": "bundle.js", - "path": "/home/rruan1/swegram/frontend/dist/bundle.js", - "publicPath": "http://0.0.0.0:8000/static/bundle.js" + "path": "/home/rruan1/swegram_dev/swegram/frontend/dist/bundle.js", + "publicPath": "http://0.0.0.0:8080/bundle.js" }, "index.html": { "name": "index.html", - "path": "/home/rruan1/swegram/frontend/dist/index.html", - "publicPath": "http://0.0.0.0:8000/static/index.html" + "path": "/home/rruan1/swegram_dev/swegram/frontend/dist/index.html", + "publicPath": "http://0.0.0.0:8080/index.html" }, "favicon.ico": { "name": "favicon.ico", - "path": "/home/rruan1/swegram/frontend/dist/favicon.ico", - "publicPath": "http://0.0.0.0:8000/static/favicon.ico" + "path": "/home/rruan1/swegram_dev/swegram/frontend/dist/favicon.ico", + "publicPath": "http://0.0.0.0:8080/favicon.ico" } }, "chunks": { @@ -48,5 +48,5 @@ "bundle.js" ] }, - "publicPath": "http://0.0.0.0:8000/static/" + "publicPath": "http://0.0.0.0:8080/" } \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 1b933ad..7dbb6b4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ Cython jellyfish openpyxl +psycopg2 python-Levenshtein requests wheel diff --git a/swegram/settings/base.py b/swegram/settings/base.py index 65aaefc..29d68b4 100644 --- a/swegram/settings/base.py +++ b/swegram/settings/base.py @@ -75,7 +75,7 @@ STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'swegram_main/static'), - os.path.join(BASE_DIR, 'frontend/dist'), + # os.path.join(BASE_DIR, 'frontend/dist') ) WEBPACK_LOADER = { @@ -85,6 +85,8 @@ } } +CORS_ORIGIN_ALLOW_ALL = True + LOGGING_CONFIG = None import logging.config diff --git a/swegram/settings/beta.py b/swegram/settings/beta.py index 97f8a57..da346ba 100644 --- a/swegram/settings/beta.py +++ b/swegram/settings/beta.py @@ -9,8 +9,9 @@ # STATIC_ROOT = "/local/etc/httpd/html/static/swegram/dev/" # STATIC_URL = '/static/swegram/dev/' -STATIC_ROOT = "/opt/swegram/frontend/dist/" -STATIC_URL = "/static/" +# STATIC_ROOT = "/opt/swegram/frontend/dist/" +STATIC_ROOT = "/home/rruan1/swegram_dev/swegram/frontend/dist/" +STATIC_URL = "/swegrambetastatic/" ''' DATABASES = { @@ -25,6 +26,13 @@ } ''' +# To test connection with postgreql +# psql -U swegram -h 127.0.0.1 -d swegram -p 5432 -W +# enter password + +# works with the following command to connect swegram2 +# psql -d swegram2 -u rex -h numerus -p 5432 -W + DATABASES = { 'default': { 'ENGINE': "django.db.backends.postgresql_psycopg2", @@ -36,10 +44,11 @@ } } + CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.db.DatabaseCache', - 'LOCATION': 'unique_snowflake', + 'LOCATION': 'unique_snowflake' } } diff --git a/swegram/wsgi.py b/swegram/wsgi.py old mode 100644 new mode 100755 diff --git a/swegram_main/pipeline/pipeline.py b/swegram_main/pipeline/pipeline.py index 1f0a4a7..aa04156 100644 --- a/swegram_main/pipeline/pipeline.py +++ b/swegram_main/pipeline/pipeline.py @@ -1,6 +1,5 @@ """Module of pipeline - Unclear how compound check performs """ @@ -11,6 +10,7 @@ from shutil import SameFileError from typing import Optional from swegram_main.data.texts import TextDirectory as TD +from swegram_main.lib.logger import get_logger from swegram_main.pipeline.preprocess import preprocess from swegram_main.pipeline.postprocess import aggregate_conlls, save from swegram_main.pipeline.postprocess import postprocess as _postprocess @@ -18,7 +18,6 @@ from swegram_main.pipeline.lib.parse import parse as parse_ from swegram_main.pipeline.lib.tokenize import tokenize as tokenize_ from swegram_main.pipeline.lib.tag import tag as tag_ -from swegram_main.lib.logger import get_logger logger = get_logger(__name__) diff --git a/swegram_main/postgresql/client.py b/swegram_main/postgresql/client.py new file mode 100644 index 0000000..e69de29 diff --git a/swegram_main/postgresql/setup.py b/swegram_main/postgresql/setup.py new file mode 100644 index 0000000..0e3f0b0 --- /dev/null +++ b/swegram_main/postgresql/setup.py @@ -0,0 +1,3 @@ +"""Setup postgresql server + +""" \ No newline at end of file