From efa56a2bb27189aac1648c1fbc425968e825b456 Mon Sep 17 00:00:00 2001 From: sosguns2002 Date: Fri, 23 Mar 2018 16:02:35 +0200 Subject: [PATCH] Save as new profile functionality --- .../src/app/app-routing.module.ts | 2 +- .../configuration/configuration.component.ts | 7 +++- .../resultspreview.component.html | 5 +-- .../resultspreview.component.ts | 1 + .../settings/settings.component.html | 8 ++--- .../settings/settings.component.ts | 20 +++++------- .../app/configuration/settings/settings.ts | 1 + .../manageprofiles.component.html | 4 +-- .../manageprofiles.component.ts | 4 +++ .../src/app/manageprofiles/profile-data.ts | 1 + .../saveprofile/saveprofile.component.html | 9 ++++-- .../app/saveprofile/saveprofile.component.ts | 17 +++++++--- .../stepsnvabar/stepsnvabar.component.html | 2 +- .../app/stepsnvabar/stepsnvabar.component.ts | 14 ++++++-- .../src/assets/css/interactive-mining.css | 20 ++++++++++-- .../madoap/src/madserverv3.py | 32 ++++++++++++------- 16 files changed, 100 insertions(+), 47 deletions(-) diff --git a/interactive-mining-angular-frontend/src/app/app-routing.module.ts b/interactive-mining-angular-frontend/src/app/app-routing.module.ts index 1a67502..6eb63c8 100755 --- a/interactive-mining-angular-frontend/src/app/app-routing.module.ts +++ b/interactive-mining-angular-frontend/src/app/app-routing.module.ts @@ -2,7 +2,7 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; export const AppRoutes: Routes = [ - { path: '', redirectTo: '/mining', pathMatch: 'full' } + { path: '', redirectTo: '/mining/manage-profiles', pathMatch: 'full' } ]; @NgModule({ diff --git a/interactive-mining-angular-frontend/src/app/configuration/configuration.component.ts b/interactive-mining-angular-frontend/src/app/configuration/configuration.component.ts index 6123fd6..1c24b69 100755 --- a/interactive-mining-angular-frontend/src/app/configuration/configuration.component.ts +++ b/interactive-mining-angular-frontend/src/app/configuration/configuration.component.ts @@ -43,10 +43,15 @@ export class ConfigurationComponent implements OnInit, AfterViewInit { if (!localStorage.getItem('stopwords') || localStorage.getItem('stopwords') === 'undefined') { localStorage.setItem('stopwords', '0'); } + if (!localStorage.getItem('lowercase') || localStorage.getItem('lowercase') === 'undefined') { + localStorage.setItem('lowercase', '0'); + } + if (!localStorage.getItem('stemming') || localStorage.getItem('stemming') === 'undefined') { + localStorage.setItem('stemming', '0'); + } } promptToLeave(nextUrl: string): boolean { - console.log(nextUrl); if (nextUrl.indexOf('upload-content') >= 0 || nextUrl.indexOf('configure-profile') >= 0 || nextUrl.indexOf('save-profile') >= 0) { return true; } else { diff --git a/interactive-mining-angular-frontend/src/app/configuration/resultspreview/resultspreview.component.html b/interactive-mining-angular-frontend/src/app/configuration/resultspreview/resultspreview.component.html index 220abf9..5421922 100755 --- a/interactive-mining-angular-frontend/src/app/configuration/resultspreview/resultspreview.component.html +++ b/interactive-mining-angular-frontend/src/app/configuration/resultspreview/resultspreview.component.html @@ -1,7 +1,7 @@

Test area

- +
@@ -38,8 +38,9 @@ or
- Upload your documents + Upload your documents
+
diff --git a/interactive-mining-angular-frontend/src/app/configuration/resultspreview/resultspreview.component.ts b/interactive-mining-angular-frontend/src/app/configuration/resultspreview/resultspreview.component.ts index 84a3684..a89dd6b 100755 --- a/interactive-mining-angular-frontend/src/app/configuration/resultspreview/resultspreview.component.ts +++ b/interactive-mining-angular-frontend/src/app/configuration/resultspreview/resultspreview.component.ts @@ -86,6 +86,7 @@ export class ResultspreviewComponent implements OnInit { punctuation: Number.parseInt(localStorage.getItem('punctuation')), stopwords: Number.parseInt(localStorage.getItem('stopwords')), lowercase: Number.parseInt(localStorage.getItem('lowercase')), + stemming: Number.parseInt(localStorage.getItem('stemming')), }; } diff --git a/interactive-mining-angular-frontend/src/app/configuration/settings/settings.component.html b/interactive-mining-angular-frontend/src/app/configuration/settings/settings.component.html index 3b32cf9..46da99a 100755 --- a/interactive-mining-angular-frontend/src/app/configuration/settings/settings.component.html +++ b/interactive-mining-angular-frontend/src/app/configuration/settings/settings.component.html @@ -7,7 +7,7 @@ High
recall
- +
Hight
precision
@@ -153,9 +153,9 @@
- - - +
+ +
diff --git a/interactive-mining-angular-frontend/src/app/configuration/settings/settings.component.ts b/interactive-mining-angular-frontend/src/app/configuration/settings/settings.component.ts index 01dc6f8..e2089a7 100755 --- a/interactive-mining-angular-frontend/src/app/configuration/settings/settings.component.ts +++ b/interactive-mining-angular-frontend/src/app/configuration/settings/settings.component.ts @@ -12,7 +12,6 @@ import {ActivatedRoute, Router} from '@angular/router'; }) export class SettingsComponent implements OnInit { - public sliderValue = 0; public sliderConfig: any = { connect: [true, false], tooltips: [ true ], @@ -68,6 +67,7 @@ export class SettingsComponent implements OnInit { punctuation: Number.parseInt(localStorage.getItem('punctuation')), stopwords: Number.parseInt(localStorage.getItem('stopwords')), lowercase: Number.parseInt(localStorage.getItem('lowercase')), + stemming: Number.parseInt(localStorage.getItem('stemming')), }; // show positive phrases this.positivePhrasesArray.length = 0; @@ -88,15 +88,13 @@ export class SettingsComponent implements OnInit { const content = new Phrase(); content.phrase = key; content.weight = negphrases[key]; - this.positivePhrasesArray.push(content); + this.negativePhrasesArray.push(content); } } } onSliderChange(value: number): void { - value = value + 1; localStorage.setItem('wordssplitnum', value.toString()); - this.settings.wordssplitnum = value; } advancedCheckboxChange() { @@ -207,14 +205,6 @@ export class SettingsComponent implements OnInit { this.getSettingsFromLocalStorage(); } - wordssplitnumChange(value): void { - if (value < 0 || value > 10) { - return; - } - localStorage.setItem('wordssplitnum', value); - this.settings.wordssplitnum = value; - } - stopwordsCheckBoxChange(value: boolean): void { localStorage.setItem('stopwords', value ? '1' : '0'); this.settings.stopwords = value ? 1 : 0; @@ -230,6 +220,11 @@ export class SettingsComponent implements OnInit { this.settings.lowercase = value ? 1 : 0; } + stemmingCheckBoxChange(value: boolean): void { + localStorage.setItem('stemming', value ? '1' : '0'); + this.settings.stemming = value ? 1 : 0; + } + getSettingsFromLocalStorage(): Settings { return this.settings = { docname: localStorage.getItem('docname'), @@ -243,6 +238,7 @@ export class SettingsComponent implements OnInit { punctuation: Number.parseInt(localStorage.getItem('punctuation')), stopwords: Number.parseInt(localStorage.getItem('stopwords')), lowercase: Number.parseInt(localStorage.getItem('lowercase')), + stemming: Number.parseInt(localStorage.getItem('stemming')), }; } diff --git a/interactive-mining-angular-frontend/src/app/configuration/settings/settings.ts b/interactive-mining-angular-frontend/src/app/configuration/settings/settings.ts index 069e5a5..6f18162 100755 --- a/interactive-mining-angular-frontend/src/app/configuration/settings/settings.ts +++ b/interactive-mining-angular-frontend/src/app/configuration/settings/settings.ts @@ -10,4 +10,5 @@ export interface Settings { punctuation: number; stopwords: number; lowercase: number; + stemming: number; } diff --git a/interactive-mining-angular-frontend/src/app/manageprofiles/manageprofiles.component.html b/interactive-mining-angular-frontend/src/app/manageprofiles/manageprofiles.component.html index 8811cde..3ca6b13 100755 --- a/interactive-mining-angular-frontend/src/app/manageprofiles/manageprofiles.component.html +++ b/interactive-mining-angular-frontend/src/app/manageprofiles/manageprofiles.component.html @@ -1,7 +1,7 @@
-

Your mining profiles

+

Your mining profiles

@@ -50,7 +50,7 @@ -
    diff --git a/interactive-mining-angular-frontend/src/app/manageprofiles/manageprofiles.component.ts b/interactive-mining-angular-frontend/src/app/manageprofiles/manageprofiles.component.ts index b08168b..0009575 100755 --- a/interactive-mining-angular-frontend/src/app/manageprofiles/manageprofiles.component.ts +++ b/interactive-mining-angular-frontend/src/app/manageprofiles/manageprofiles.component.ts @@ -70,6 +70,7 @@ export class ManageprofilesComponent implements OnInit { localStorage.setItem('punctuation', res.punctuation); localStorage.setItem('stopwords', res.stopwords); localStorage.setItem('lowercase', res.lowercase); + localStorage.setItem('stemming', res.stemming); this.router.navigate(['../upload-content'], {relativeTo: this.route, queryParamsHandling: 'preserve'}); }); } @@ -116,6 +117,7 @@ export class ManageprofilesComponent implements OnInit { localStorage.setItem('punctuation', res.punctuation); localStorage.setItem('stopwords', res.stopwords); localStorage.setItem('lowercase', res.lowercase); + localStorage.setItem('stemming', res.stemming); this.router.navigate(['../upload-content'], {relativeTo: this.route, queryParamsHandling: 'preserve'}); }); } @@ -145,6 +147,7 @@ export class ManageprofilesComponent implements OnInit { localStorage.setItem('punctuation', res.punctuation); localStorage.setItem('stopwords', res.stopwords); localStorage.setItem('lowercase', res.lowercase); + localStorage.setItem('stemming', res.stemming); this.router.navigate(['../upload-content'], {relativeTo: this.route, queryParamsHandling: 'preserve'}); }); } @@ -166,6 +169,7 @@ export class ManageprofilesComponent implements OnInit { localStorage.removeItem('punctuation'); localStorage.removeItem('stopwords'); localStorage.removeItem('lowercase'); + localStorage.removeItem('stemming'); } } diff --git a/interactive-mining-angular-frontend/src/app/manageprofiles/profile-data.ts b/interactive-mining-angular-frontend/src/app/manageprofiles/profile-data.ts index 88dab01..0979ce4 100755 --- a/interactive-mining-angular-frontend/src/app/manageprofiles/profile-data.ts +++ b/interactive-mining-angular-frontend/src/app/manageprofiles/profile-data.ts @@ -11,4 +11,5 @@ export interface ProfileData { punctuation: string; stopwords: string; lowercase: string; + stemming: string; } diff --git a/interactive-mining-angular-frontend/src/app/saveprofile/saveprofile.component.html b/interactive-mining-angular-frontend/src/app/saveprofile/saveprofile.component.html index dab0afb..98f98b0 100755 --- a/interactive-mining-angular-frontend/src/app/saveprofile/saveprofile.component.html +++ b/interactive-mining-angular-frontend/src/app/saveprofile/saveprofile.component.html @@ -1,9 +1,12 @@
    -
    - +
    + +
    or
    + Profile name cannot be empty! - + +
    diff --git a/interactive-mining-angular-frontend/src/app/saveprofile/saveprofile.component.ts b/interactive-mining-angular-frontend/src/app/saveprofile/saveprofile.component.ts index 45d2662..642d16d 100755 --- a/interactive-mining-angular-frontend/src/app/saveprofile/saveprofile.component.ts +++ b/interactive-mining-angular-frontend/src/app/saveprofile/saveprofile.component.ts @@ -10,6 +10,7 @@ import {ActivatedRoute, Router} from '@angular/router'; }) export class SaveprofileComponent implements OnInit { + public profileId = ''; public profileName = 'New profile name'; public docnName = ''; public docsNumber = 0; @@ -17,9 +18,12 @@ export class SaveprofileComponent implements OnInit { constructor(private saveprofileService: SaveprofileService, private route: ActivatedRoute, private router: Router) { } ngOnInit() { - if (localStorage.getItem('profilename') && localStorage.getItem('profilename') !== 'undefined') { - this.profileName = localStorage.getItem('profilename'); + if (localStorage.getItem('profileid') && localStorage.getItem('profileid') !== 'undefined') { + this.profileId = localStorage.getItem('profileid'); } + // if (localStorage.getItem('profilename') && localStorage.getItem('profilename') !== 'undefined') { + // this.profileName = localStorage.getItem('profilename'); + // } if (localStorage.getItem('docname') && localStorage.getItem('docname') !== 'undefined') { this.docnName = localStorage.getItem('docname'); } @@ -28,7 +32,12 @@ export class SaveprofileComponent implements OnInit { } } - saveProfile(): void { + saveCurrentProfile(): void { + this.saveprofileService.saveProfile(this.profileName, this.profileId, this.docnName, this.docsNumber) + .subscribe(() => this.router.navigate(['../manage-profiles'], {relativeTo: this.route, queryParamsHandling: 'preserve'})); + } + + saveNewProfile(): void { if (this.profileName === '') { UIkit.notification({ message: 'You have to provide a name to your new profile', @@ -38,7 +47,7 @@ export class SaveprofileComponent implements OnInit { }); return; } else { - this.saveprofileService.saveProfile(this.profileName, localStorage.getItem('profileid'), this.docnName, this.docsNumber) + this.saveprofileService.saveProfile(this.profileName, '', this.docnName, this.docsNumber) .subscribe(() => this.router.navigate(['../manage-profiles'], {relativeTo: this.route, queryParamsHandling: 'preserve'})); } } diff --git a/interactive-mining-angular-frontend/src/app/stepsnvabar/stepsnvabar.component.html b/interactive-mining-angular-frontend/src/app/stepsnvabar/stepsnvabar.component.html index 5539a0c..fe5d18c 100755 --- a/interactive-mining-angular-frontend/src/app/stepsnvabar/stepsnvabar.component.html +++ b/interactive-mining-angular-frontend/src/app/stepsnvabar/stepsnvabar.component.html @@ -31,7 +31,7 @@
    - + Add concepts Configure matching proccess Save matching profile diff --git a/interactive-mining-angular-frontend/src/app/stepsnvabar/stepsnvabar.component.ts b/interactive-mining-angular-frontend/src/app/stepsnvabar/stepsnvabar.component.ts index 0779003..2aaab29 100755 --- a/interactive-mining-angular-frontend/src/app/stepsnvabar/stepsnvabar.component.ts +++ b/interactive-mining-angular-frontend/src/app/stepsnvabar/stepsnvabar.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import {ActivatedRoute, NavigationEnd, Router} from '@angular/router'; +import UIkit from 'uikit'; @Component({ selector: 'app-stepsnvabar', @@ -8,7 +9,7 @@ import {ActivatedRoute, NavigationEnd, Router} from '@angular/router'; }) export class StepsnvabarComponent implements OnInit { - private proccessStep = 0; + public proccessStep = 0; constructor(private route: ActivatedRoute, private router: Router) { router.events.subscribe((val) => { @@ -33,8 +34,15 @@ export class StepsnvabarComponent implements OnInit { } } - cancelHandle(): void { - this.router.navigate(['../manage-profiles'], {relativeTo: this.route, queryParamsHandling: 'preserve'}); + cancelHandle(proccessStep: number): void { + if (proccessStep === 3) { + UIkit.modal.confirm('' + + 'Your changes have not been saved to your Profile!
    Are you sure you want to leave?
    ', {escClose: true}).then(() => { + this.router.navigate(['../manage-profiles'], {relativeTo: this.route, queryParamsHandling: 'preserve'}); + }, () => false); + } else { + this.router.navigate(['../manage-profiles'], {relativeTo: this.route, queryParamsHandling: 'preserve'}); + } } } diff --git a/interactive-mining-angular-frontend/src/assets/css/interactive-mining.css b/interactive-mining-angular-frontend/src/assets/css/interactive-mining.css index 1763e9e..8a75f15 100755 --- a/interactive-mining-angular-frontend/src/assets/css/interactive-mining.css +++ b/interactive-mining-angular-frontend/src/assets/css/interactive-mining.css @@ -713,14 +713,17 @@ width: 1px; } html:not([dir=rtl]) .noUi-horizontal .noUi-handle { - right: -15px; + right: -12px; } .noUi-horizontal .noUi-handle { - width: 30px; + width: 25px; height: 25px; top: -10px; } +.noUi-handle:after, .noUi-handle:before { + display: none; +} .noUi-handle:after { left: 15px !important; } @@ -730,6 +733,17 @@ html:not([dir=rtl]) .noUi-horizontal .noUi-handle { } .noUi-handle { cursor: pointer; + border: 4px solid #f9f9f9; + border-radius: 25px; + background: var(--cm-theme-6); + box-shadow: 0 1px 5px 0px #748188; +} +.noUi-active { + background: var(--cm-theme-5); + box-shadow: 0 1px 5px 0px #748188; +} +.noUi-horizontal .noUi-tooltip { + bottom: 145%; } @@ -1077,7 +1091,7 @@ header.uk-sticky-fixed .cm-results-count-section { padding-bottom: 20px; /*border: 1px solid #f7c800;*/ padding-left: 20px; - min-height: 667px; + min-height: 745px; } #child2 { position: relative; diff --git a/interactive-mining-backend/madoap/src/madserverv3.py b/interactive-mining-backend/madoap/src/madserverv3.py index 4d53daa..5ceefea 100755 --- a/interactive-mining-backend/madoap/src/madserverv3.py +++ b/interactive-mining-backend/madoap/src/madserverv3.py @@ -1202,9 +1202,10 @@ class RunMiningHandler(BaseHandler): for key, value in pos_words.iteritems(): # MONO GIA TO EGI if 'lowercase' in mining_parameters and mining_parameters['lowercase'] == "1": - pos_set += r'regexpcountuniquematches("%s",%s)*%s + ' % (key.decode('utf-8').lower(),j2scontext,value) - else: - pos_set += r'regexpcountuniquematches("%s",%s)*%s + ' % (key,j2scontext,value) + key = key.decode('utf-8').lower() + if 'stemming' in mining_parameters and mining_parameters['stemming'] == "1": + key = 'stem('+key+')' + pos_set += r'regexpcountuniquematches("%s",%s)*%s + ' % (key,j2scontext,value) # ORIGINAL # pos_set += r'regexpcountuniquematches("(?:\b)%s(?:\b)",j2s(prev,middle,next))*%s + ' % (key,value) data['poswords'].append(key) @@ -1216,9 +1217,10 @@ class RunMiningHandler(BaseHandler): for key, value in neg_words.iteritems(): # MONO GIA TO EGI if 'lowercase' in mining_parameters and mining_parameters['lowercase'] == "1": - neg_set += r'regexpcountuniquematches("%s",%s)*%s + ' % (key.decode('utf-8').lower(),j2scontext,value) - else: - neg_set += r'regexpcountuniquematches("%s",%s)*%s + ' % (key,j2scontext,value) + key = key.decode('utf-8').lower() + if 'stemming' in mining_parameters and mining_parameters['stemming'] == "1": + key = 'stem('+key+')' + neg_set += r'regexpcountuniquematches("%s",%s)*%s + ' % (key,j2scontext,value) # ORIGINAL # neg_set += r'regexpcountuniquematches("(?:\b)%s(?:\b)",j2s(prev,middle,next))*%s - ' % (key,value) data['negwords'].append(key) @@ -1245,7 +1247,9 @@ class RunMiningHandler(BaseHandler): if 'stopwords' in mining_parameters and mining_parameters['stopwords'] == "1": doc_filters = 'filterstopwords('+doc_filters+')' ackn_filters = 'filterstopwords('+ackn_filters+')' - print "DOCCC", doc_filters + if 'stemming' in mining_parameters and mining_parameters['stemming'] == "1": + doc_filters = 'stem('+doc_filters+')' + ackn_filters = 'stem('+ackn_filters+')' list(cursor.execute("drop table if exists grantstemp"+user_id, parse=False)) query_pre_grants = "create temp table grantstemp{0} as select stripchars(p1) as gt1, case when p2 is null then null else {1} end as gt2 from (setschema 'p1,p2' file 'users_files/p{0}.tsv' dialect:tsv)".format(user_id, ackn_filters) cursor.execute(query_pre_grants) @@ -1261,9 +1265,13 @@ class RunMiningHandler(BaseHandler): # string concatenation workaround because of the special characters conflicts if 'wordssplitnum' in mining_parameters and mining_parameters['wordssplitnum'] != '': words_split = int(mining_parameters['wordssplitnum']) + # TODO must correct this!!! + words_split = words_split + 1 gt2 = 'gt2' if 'lowercase' in mining_parameters and mining_parameters['lowercase'] == "1": gt2 = 'lower('+gt2+')' + if 'stemming' in mining_parameters and mining_parameters['stemming'] == "1": + gt2 = 'stem('+gt2+')' # MONO GIA TO EGI if 0 < words_split and words_split <= 20: acknowledgment_split = r'textwindow2s('+gt2+',0,'+str(words_split)+r',0)' @@ -1371,14 +1379,16 @@ class PrepareSavedProfileHandler(BaseHandler): filters['contextprev'] = profile_parameters['contextprev'] if 'contextnext' in profile_parameters and profile_parameters['contextnext'] != '': filters['contextnext'] = profile_parameters['contextnext'] - if 'lettercase' in profile_parameters and profile_parameters['lettercase'] != '': - filters['lettercase'] = profile_parameters['lettercase'] + if 'lowercase' in profile_parameters and profile_parameters['lowercase'] != '': + filters['lowercase'] = profile_parameters['lowercase'] if 'wordssplitnum' in profile_parameters and profile_parameters['wordssplitnum'] != '': filters['wordssplitnum'] = profile_parameters['wordssplitnum'] if 'stopwords' in profile_parameters and profile_parameters['stopwords'] != '': filters['stopwords'] = profile_parameters['stopwords'] - if 'stopwords' in profile_parameters and profile_parameters['stopwords'] != '': + if 'punctuation' in profile_parameters and profile_parameters['punctuation'] != '': filters['punctuation'] = profile_parameters['punctuation'] + if 'stemming' in profile_parameters and profile_parameters['stemming'] != '': + filters['stemming'] = profile_parameters['stemming'] cursor.executemany("insert into filters(c1,c2) values(?,?)", ( (key, value,) for key, value in filters.iteritems() @@ -1452,7 +1462,7 @@ class SaveProfileToDatabaseHandler(BaseHandler): cursor=madis.functions.Connection(database_file_name).cursor() user_profiles = [] if old_profile: - query = 'UPDATE database set name="{1}", datecreated="{2}", status="{3}", matches="{4}", docname="{5}", docsnumber="{6}" where id="{0}"'.format(profile_id,profile_name,datetime.date.today(),"Ready","8/8",doc_name,docs_number) + query = 'UPDATE database set datecreated="{2}", status="{3}", matches="{4}", docname="{5}", docsnumber="{6}" where id="{0}"'.format(profile_id,profile_name,datetime.date.today().strftime("%B %d %Y"),"Ready","8/8",doc_name,docs_number) else: query = 'INSERT INTO database VALUES("{0}","{1}","{2}","{3}","{4}","{5}","{6}")'.format(profile_id,profile_name,datetime.date.today().strftime("%B %d %Y"),"Saved","8/8",doc_name,docs_number) cursor.execute(query, parse=False)