Save as new profile functionality

This commit is contained in:
sosguns2002 2018-03-23 16:02:35 +02:00
parent 4244193375
commit efa56a2bb2
16 changed files with 100 additions and 47 deletions

View File

@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
export const AppRoutes: Routes = [ export const AppRoutes: Routes = [
{ path: '', redirectTo: '/mining', pathMatch: 'full' } { path: '', redirectTo: '/mining/manage-profiles', pathMatch: 'full' }
]; ];
@NgModule({ @NgModule({

View File

@ -43,10 +43,15 @@ export class ConfigurationComponent implements OnInit, AfterViewInit {
if (!localStorage.getItem('stopwords') || localStorage.getItem('stopwords') === 'undefined') { if (!localStorage.getItem('stopwords') || localStorage.getItem('stopwords') === 'undefined') {
localStorage.setItem('stopwords', '0'); 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 { promptToLeave(nextUrl: string): boolean {
console.log(nextUrl);
if (nextUrl.indexOf('upload-content') >= 0 || nextUrl.indexOf('configure-profile') >= 0 || nextUrl.indexOf('save-profile') >= 0) { if (nextUrl.indexOf('upload-content') >= 0 || nextUrl.indexOf('configure-profile') >= 0 || nextUrl.indexOf('save-profile') >= 0) {
return true; return true;
} else { } else {

View File

@ -1,7 +1,7 @@
<div class="uk-grid-collapse uk-child-width-expand uk-text-middle" uk-grid> <div class="uk-grid-collapse uk-child-width-expand uk-text-middle" uk-grid>
<h4 class="cm-margin-medium">Test area</h4> <h4 class="cm-margin-medium">Test area</h4>
<div class="uk-text-right"> <div class="uk-text-right">
<button id="next-button" class="uk-button cm-button-primary uk-margin-small-top" (click)="saveProfile()">Save profile</button> <button id="next-button" class="uk-button cm-button-primary uk-margin-small-top" (click)="saveProfile()">Continue</button>
</div> </div>
</div> </div>
<div class="cm-results-section"> <div class="cm-results-section">
@ -38,8 +38,9 @@
<span class="uk-text-middle">or</span> <span class="uk-text-middle">or</span>
<div uk-form-custom> <div uk-form-custom>
<input #docupload type="file" (change)="fileChangeUpload($event);docupload.value=''" accept=".txt,.pdf"> <input #docupload type="file" (change)="fileChangeUpload($event);docupload.value=''" accept=".txt,.pdf">
<span class="uk-link">Upload your documents <span class="cm-tooltip" uk-icon="icon: info" title="Upload either <b>1 single PDF</b> or <b>1 single TXT</b> file or a valid <b>JSON file with two keys (id, text)</b> JSON files are necessary when you want to test the algorithm in many publications."></span></span> <span class="uk-link">Upload your documents</span>
</div> </div>
<span class="cm-tooltip" uk-icon="icon: info" title="Upload either <b>1 single PDF</b> or <b>1 single TXT</b> file or a valid <b>JSON file with two keys (id, text)</b> JSON files are necessary when you want to test the algorithm in <b>many publications.</b>" uk-tooltip="pos: right"></span>
</div> </div>
</div> </div>

View File

@ -86,6 +86,7 @@ export class ResultspreviewComponent implements OnInit {
punctuation: Number.parseInt(localStorage.getItem('punctuation')), punctuation: Number.parseInt(localStorage.getItem('punctuation')),
stopwords: Number.parseInt(localStorage.getItem('stopwords')), stopwords: Number.parseInt(localStorage.getItem('stopwords')),
lowercase: Number.parseInt(localStorage.getItem('lowercase')), lowercase: Number.parseInt(localStorage.getItem('lowercase')),
stemming: Number.parseInt(localStorage.getItem('stemming')),
}; };
} }

View File

@ -7,7 +7,7 @@
<span>High<br>recall</span> <span>High<br>recall</span>
</div> </div>
<div class="uk-width-expand@m"> <div class="uk-width-expand@m">
<nouislider [config]="sliderConfig" [(ngModel)]="sliderValue" (ngModelChange)="onSliderChange($event)"></nouislider> <nouislider [config]="sliderConfig" [(ngModel)]="settings.wordssplitnum" (ngModelChange)="onSliderChange($event)"></nouislider>
</div> </div>
<div class="uk-width-auto uk-grid-item-match"> <div class="uk-width-auto uk-grid-item-match">
<span>Hight<br>precision</span> <span>Hight<br>precision</span>
@ -153,9 +153,9 @@
<div class="uk-margin"> <div class="uk-margin">
<label class="uk-form-label" for="lowercase-filter"><input id="lowercase-filter" class="uk-checkbox" type="checkbox" [checked]="settings.lowercase===1" (change)="lowercaseCheckBoxChange($event.target.checked)"> Convert to lower case</label> <label class="uk-form-label" for="lowercase-filter"><input id="lowercase-filter" class="uk-checkbox" type="checkbox" [checked]="settings.lowercase===1" (change)="lowercaseCheckBoxChange($event.target.checked)"> Convert to lower case</label>
</div> </div>
<!--<div class="uk-margin">--> <div class="uk-margin">
<!--<label class="uk-form-label" for="stemming-filter"><input id="stemming-filter" class="uk-checkbox" type="checkbox" [checked]="settings.stemming===1" (change)="stemmingCheckBoxChange($event.target.checked)"> Word stemming <span class="cm-tooltip" uk-icon="icon: info" title="If you want the tooltip to appear with a little delay, just add the delay option to the uk-tooltip attribute with your value in milliseconds." uk-tooltip="pos: right"></span></label>--> <label class="uk-form-label" for="stemming-filter"><input id="stemming-filter" class="uk-checkbox" type="checkbox" [checked]="settings.stemming===1" (change)="stemmingCheckBoxChange($event.target.checked)"> Word stemming <span class="cm-tooltip" uk-icon="icon: info" title="Stemming is a process of text normalisation, in which the <b>variant forms of a word are reduced to a common form</b>, for <b>example</b>:<br>connection, connections, connective, connected, connecting<br><b>are reduced to connect</b>." uk-tooltip="pos: right"></span></label>
<!--</div>--> </div>
</form> </form>
</div> </div>
</li> </li>

View File

@ -12,7 +12,6 @@ import {ActivatedRoute, Router} from '@angular/router';
}) })
export class SettingsComponent implements OnInit { export class SettingsComponent implements OnInit {
public sliderValue = 0;
public sliderConfig: any = { public sliderConfig: any = {
connect: [true, false], connect: [true, false],
tooltips: [ true ], tooltips: [ true ],
@ -68,6 +67,7 @@ export class SettingsComponent implements OnInit {
punctuation: Number.parseInt(localStorage.getItem('punctuation')), punctuation: Number.parseInt(localStorage.getItem('punctuation')),
stopwords: Number.parseInt(localStorage.getItem('stopwords')), stopwords: Number.parseInt(localStorage.getItem('stopwords')),
lowercase: Number.parseInt(localStorage.getItem('lowercase')), lowercase: Number.parseInt(localStorage.getItem('lowercase')),
stemming: Number.parseInt(localStorage.getItem('stemming')),
}; };
// show positive phrases // show positive phrases
this.positivePhrasesArray.length = 0; this.positivePhrasesArray.length = 0;
@ -88,15 +88,13 @@ export class SettingsComponent implements OnInit {
const content = new Phrase(); const content = new Phrase();
content.phrase = key; content.phrase = key;
content.weight = negphrases[key]; content.weight = negphrases[key];
this.positivePhrasesArray.push(content); this.negativePhrasesArray.push(content);
} }
} }
} }
onSliderChange(value: number): void { onSliderChange(value: number): void {
value = value + 1;
localStorage.setItem('wordssplitnum', value.toString()); localStorage.setItem('wordssplitnum', value.toString());
this.settings.wordssplitnum = value;
} }
advancedCheckboxChange() { advancedCheckboxChange() {
@ -207,14 +205,6 @@ export class SettingsComponent implements OnInit {
this.getSettingsFromLocalStorage(); this.getSettingsFromLocalStorage();
} }
wordssplitnumChange(value): void {
if (value < 0 || value > 10) {
return;
}
localStorage.setItem('wordssplitnum', value);
this.settings.wordssplitnum = value;
}
stopwordsCheckBoxChange(value: boolean): void { stopwordsCheckBoxChange(value: boolean): void {
localStorage.setItem('stopwords', value ? '1' : '0'); localStorage.setItem('stopwords', value ? '1' : '0');
this.settings.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; this.settings.lowercase = value ? 1 : 0;
} }
stemmingCheckBoxChange(value: boolean): void {
localStorage.setItem('stemming', value ? '1' : '0');
this.settings.stemming = value ? 1 : 0;
}
getSettingsFromLocalStorage(): Settings { getSettingsFromLocalStorage(): Settings {
return this.settings = { return this.settings = {
docname: localStorage.getItem('docname'), docname: localStorage.getItem('docname'),
@ -243,6 +238,7 @@ export class SettingsComponent implements OnInit {
punctuation: Number.parseInt(localStorage.getItem('punctuation')), punctuation: Number.parseInt(localStorage.getItem('punctuation')),
stopwords: Number.parseInt(localStorage.getItem('stopwords')), stopwords: Number.parseInt(localStorage.getItem('stopwords')),
lowercase: Number.parseInt(localStorage.getItem('lowercase')), lowercase: Number.parseInt(localStorage.getItem('lowercase')),
stemming: Number.parseInt(localStorage.getItem('stemming')),
}; };
} }

View File

@ -10,4 +10,5 @@ export interface Settings {
punctuation: number; punctuation: number;
stopwords: number; stopwords: number;
lowercase: number; lowercase: number;
stemming: number;
} }

View File

@ -1,7 +1,7 @@
<app-stepsnvabar></app-stepsnvabar> <app-stepsnvabar></app-stepsnvabar>
<div class="uk-section uk-section-default"> <div class="uk-section uk-section-default">
<div class="uk-container uk-container-expand"> <div class="uk-container uk-container-expand">
<h4>Your mining profiles <span class="cm-tooltip" uk-icon="icon: info" title="Each <b>mining profile</b> consists of the data and the rules used to define a <b>mining procedure</b>." uk-tooltip="pos: right"></span></h4> <h4>Your mining profiles <span class="cm-tooltip" uk-icon="icon: info" title="Each <b>mining profile</b> consists of the data and the rules used to define a <b>mining procedure</b>.<br>Click the profile to <b>edit</b>." uk-tooltip="pos: right"></span></h4>
<!--<div uk-grid>--> <!--<div uk-grid>-->
<!--<div class="uk-width-expand@m">--> <!--<div class="uk-width-expand@m">-->
<div class="uk-overflow-auto"> <div class="uk-overflow-auto">
@ -50,7 +50,7 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<pagination-template #p="paginationApi" <pagination-template *ngIf="userSavedProfiles.length" #p="paginationApi"
[id]="config.id" [id]="config.id"
(pageChange)="config.currentPage = $event"> (pageChange)="config.currentPage = $event">
<ul class="uk-pagination uk-flex-center" uk-margin> <ul class="uk-pagination uk-flex-center" uk-margin>

View File

@ -70,6 +70,7 @@ export class ManageprofilesComponent implements OnInit {
localStorage.setItem('punctuation', res.punctuation); localStorage.setItem('punctuation', res.punctuation);
localStorage.setItem('stopwords', res.stopwords); localStorage.setItem('stopwords', res.stopwords);
localStorage.setItem('lowercase', res.lowercase); localStorage.setItem('lowercase', res.lowercase);
localStorage.setItem('stemming', res.stemming);
this.router.navigate(['../upload-content'], {relativeTo: this.route, queryParamsHandling: 'preserve'}); 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('punctuation', res.punctuation);
localStorage.setItem('stopwords', res.stopwords); localStorage.setItem('stopwords', res.stopwords);
localStorage.setItem('lowercase', res.lowercase); localStorage.setItem('lowercase', res.lowercase);
localStorage.setItem('stemming', res.stemming);
this.router.navigate(['../upload-content'], {relativeTo: this.route, queryParamsHandling: 'preserve'}); 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('punctuation', res.punctuation);
localStorage.setItem('stopwords', res.stopwords); localStorage.setItem('stopwords', res.stopwords);
localStorage.setItem('lowercase', res.lowercase); localStorage.setItem('lowercase', res.lowercase);
localStorage.setItem('stemming', res.stemming);
this.router.navigate(['../upload-content'], {relativeTo: this.route, queryParamsHandling: 'preserve'}); this.router.navigate(['../upload-content'], {relativeTo: this.route, queryParamsHandling: 'preserve'});
}); });
} }
@ -166,6 +169,7 @@ export class ManageprofilesComponent implements OnInit {
localStorage.removeItem('punctuation'); localStorage.removeItem('punctuation');
localStorage.removeItem('stopwords'); localStorage.removeItem('stopwords');
localStorage.removeItem('lowercase'); localStorage.removeItem('lowercase');
localStorage.removeItem('stemming');
} }
} }

View File

@ -11,4 +11,5 @@ export interface ProfileData {
punctuation: string; punctuation: string;
stopwords: string; stopwords: string;
lowercase: string; lowercase: string;
stemming: string;
} }

View File

@ -1,9 +1,12 @@
<app-stepsnvabar></app-stepsnvabar> <app-stepsnvabar></app-stepsnvabar>
<div class="uk-section uk-section-default" style="padding-top: 20px;"> <div class="uk-section uk-section-default" style="padding-top: 20px;">
<div class="uk-container uk-width-1-2 uk-align-left"> <div class="uk-container uk-width-1-3 uk-align-left">
<label for="profile-name" [ngClass]="{'uk-text-danger':!profileName}">Profile's name:</label> <button *ngIf="profileId" class="uk-button cm-button-primary uk-width-1-1 uk-button-medium uk-text-center" (click)="saveCurrentProfile()">Save changes</button>
<div *ngIf="profileId" class="uk-heading-line uk-text-center uk-margin-medium"><span>or</span></div>
<label for="profile-name" [ngClass]="{'uk-text-danger':!profileName}">New profile's name:</label>
<input [(ngModel)]="profileName" class="uk-input" [ngClass]="{'uk-form-danger':!profileName}" id="profile-name" type="text" autofocus> <input [(ngModel)]="profileName" class="uk-input" [ngClass]="{'uk-form-danger':!profileName}" id="profile-name" type="text" autofocus>
<span *ngIf="!profileName" class="uk-text-danger">Profile name cannot be empty!</span> <span *ngIf="!profileName" class="uk-text-danger">Profile name cannot be empty!</span>
<button class="uk-button cm-button-primary uk-margin-medium-top uk-width-1-1 uk-button-medium uk-text-center" [disabled]="!profileName" (click)="saveProfile()">Save this profile</button> <button *ngIf="profileId" class="uk-button cm-button-primary cm-margin-medium-top uk-width-1-1 uk-button-medium uk-text-center" [disabled]="!profileName" (click)="saveNewProfile()">Save as new profile</button>
<button *ngIf="!profileId" class="uk-button cm-button-primary cm-margin-medium-top uk-width-1-1 uk-button-medium uk-text-center" [disabled]="!profileName" (click)="saveNewProfile()">Save profile</button>
</div> </div>
</div> </div>

View File

@ -10,6 +10,7 @@ import {ActivatedRoute, Router} from '@angular/router';
}) })
export class SaveprofileComponent implements OnInit { export class SaveprofileComponent implements OnInit {
public profileId = '';
public profileName = 'New profile name'; public profileName = 'New profile name';
public docnName = ''; public docnName = '';
public docsNumber = 0; public docsNumber = 0;
@ -17,9 +18,12 @@ export class SaveprofileComponent implements OnInit {
constructor(private saveprofileService: SaveprofileService, private route: ActivatedRoute, private router: Router) { } constructor(private saveprofileService: SaveprofileService, private route: ActivatedRoute, private router: Router) { }
ngOnInit() { ngOnInit() {
if (localStorage.getItem('profilename') && localStorage.getItem('profilename') !== 'undefined') { if (localStorage.getItem('profileid') && localStorage.getItem('profileid') !== 'undefined') {
this.profileName = localStorage.getItem('profilename'); 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') { if (localStorage.getItem('docname') && localStorage.getItem('docname') !== 'undefined') {
this.docnName = localStorage.getItem('docname'); 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 === '') { if (this.profileName === '') {
UIkit.notification({ UIkit.notification({
message: 'You have to provide a name to your new profile', message: 'You have to provide a name to your new profile',
@ -38,7 +47,7 @@ export class SaveprofileComponent implements OnInit {
}); });
return; return;
} else { } 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'})); .subscribe(() => this.router.navigate(['../manage-profiles'], {relativeTo: this.route, queryParamsHandling: 'preserve'}));
} }
} }

View File

@ -31,7 +31,7 @@
<div class="uk-container uk-container-large"> <div class="uk-container uk-container-large">
<div class="uk-grid-collapse uk-child-width-expand" uk-grid> <div class="uk-grid-collapse uk-child-width-expand" uk-grid>
<div class="cm-nav2 uk-width-expand"> <div class="cm-nav2 uk-width-expand">
<a class="cm-nav2-home" routerLink='../manage-profiles' queryParamsHandling="preserve"><span class="uk-icon" uk-icon="icon: home"></span></a> <a class="cm-nav2-home" (click)="cancelHandle(proccessStep)"><span class="uk-icon" uk-icon="icon: home"></span></a>
<a class="cm-nav2-step" [ngClass]="{'cm-nav2-step-active':proccessStep===1, 'cm-nav2-step-disabled':proccessStep<1}" [routerLink]="proccessStep>1 ? ['../upload-content'] : []" queryParamsHandling="preserve">Add concepts</a> <a class="cm-nav2-step" [ngClass]="{'cm-nav2-step-active':proccessStep===1, 'cm-nav2-step-disabled':proccessStep<1}" [routerLink]="proccessStep>1 ? ['../upload-content'] : []" queryParamsHandling="preserve">Add concepts</a>
<a class="cm-nav2-step" [ngClass]="{'cm-nav2-step-active':proccessStep===2, 'cm-nav2-step-disabled':proccessStep<2}" [routerLink]="proccessStep>2 ? ['../configure-profile'] : []" queryParamsHandling="preserve">Configure matching proccess</a> <a class="cm-nav2-step" [ngClass]="{'cm-nav2-step-active':proccessStep===2, 'cm-nav2-step-disabled':proccessStep<2}" [routerLink]="proccessStep>2 ? ['../configure-profile'] : []" queryParamsHandling="preserve">Configure matching proccess</a>
<a class="cm-nav2-step" [ngClass]="{'cm-nav2-step-active':proccessStep===3, 'cm-nav2-step-disabled':proccessStep<3}" [routerLink]="proccessStep>3 ? ['../save-profile'] : []" queryParamsHandling="preserve">Save matching profile</a> <a class="cm-nav2-step" [ngClass]="{'cm-nav2-step-active':proccessStep===3, 'cm-nav2-step-disabled':proccessStep<3}" [routerLink]="proccessStep>3 ? ['../save-profile'] : []" queryParamsHandling="preserve">Save matching profile</a>

View File

@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, NavigationEnd, Router} from '@angular/router'; import {ActivatedRoute, NavigationEnd, Router} from '@angular/router';
import UIkit from 'uikit';
@Component({ @Component({
selector: 'app-stepsnvabar', selector: 'app-stepsnvabar',
@ -8,7 +9,7 @@ import {ActivatedRoute, NavigationEnd, Router} from '@angular/router';
}) })
export class StepsnvabarComponent implements OnInit { export class StepsnvabarComponent implements OnInit {
private proccessStep = 0; public proccessStep = 0;
constructor(private route: ActivatedRoute, private router: Router) { constructor(private route: ActivatedRoute, private router: Router) {
router.events.subscribe((val) => { router.events.subscribe((val) => {
@ -33,8 +34,15 @@ export class StepsnvabarComponent implements OnInit {
} }
} }
cancelHandle(): void { cancelHandle(proccessStep: number): void {
this.router.navigate(['../manage-profiles'], {relativeTo: this.route, queryParamsHandling: 'preserve'}); if (proccessStep === 3) {
UIkit.modal.confirm('<span class="uk-text-bold">' +
'Your changes have not been saved to your Profile!<br>Are you sure you want to leave?</span>', {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'});
}
} }
} }

View File

@ -713,14 +713,17 @@
width: 1px; width: 1px;
} }
html:not([dir=rtl]) .noUi-horizontal .noUi-handle { html:not([dir=rtl]) .noUi-horizontal .noUi-handle {
right: -15px; right: -12px;
} }
.noUi-horizontal .noUi-handle { .noUi-horizontal .noUi-handle {
width: 30px; width: 25px;
height: 25px; height: 25px;
top: -10px; top: -10px;
} }
.noUi-handle:after, .noUi-handle:before {
display: none;
}
.noUi-handle:after { .noUi-handle:after {
left: 15px !important; left: 15px !important;
} }
@ -730,6 +733,17 @@ html:not([dir=rtl]) .noUi-horizontal .noUi-handle {
} }
.noUi-handle { .noUi-handle {
cursor: pointer; 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; padding-bottom: 20px;
/*border: 1px solid #f7c800;*/ /*border: 1px solid #f7c800;*/
padding-left: 20px; padding-left: 20px;
min-height: 667px; min-height: 745px;
} }
#child2 { #child2 {
position: relative; position: relative;

View File

@ -1202,9 +1202,10 @@ class RunMiningHandler(BaseHandler):
for key, value in pos_words.iteritems(): for key, value in pos_words.iteritems():
# MONO GIA TO EGI # MONO GIA TO EGI
if 'lowercase' in mining_parameters and mining_parameters['lowercase'] == "1": if 'lowercase' in mining_parameters and mining_parameters['lowercase'] == "1":
pos_set += r'regexpcountuniquematches("%s",%s)*%s + ' % (key.decode('utf-8').lower(),j2scontext,value) key = key.decode('utf-8').lower()
else: if 'stemming' in mining_parameters and mining_parameters['stemming'] == "1":
pos_set += r'regexpcountuniquematches("%s",%s)*%s + ' % (key,j2scontext,value) key = 'stem('+key+')'
pos_set += r'regexpcountuniquematches("%s",%s)*%s + ' % (key,j2scontext,value)
# ORIGINAL # ORIGINAL
# pos_set += r'regexpcountuniquematches("(?:\b)%s(?:\b)",j2s(prev,middle,next))*%s + ' % (key,value) # pos_set += r'regexpcountuniquematches("(?:\b)%s(?:\b)",j2s(prev,middle,next))*%s + ' % (key,value)
data['poswords'].append(key) data['poswords'].append(key)
@ -1216,9 +1217,10 @@ class RunMiningHandler(BaseHandler):
for key, value in neg_words.iteritems(): for key, value in neg_words.iteritems():
# MONO GIA TO EGI # MONO GIA TO EGI
if 'lowercase' in mining_parameters and mining_parameters['lowercase'] == "1": if 'lowercase' in mining_parameters and mining_parameters['lowercase'] == "1":
neg_set += r'regexpcountuniquematches("%s",%s)*%s + ' % (key.decode('utf-8').lower(),j2scontext,value) key = key.decode('utf-8').lower()
else: if 'stemming' in mining_parameters and mining_parameters['stemming'] == "1":
neg_set += r'regexpcountuniquematches("%s",%s)*%s + ' % (key,j2scontext,value) key = 'stem('+key+')'
neg_set += r'regexpcountuniquematches("%s",%s)*%s + ' % (key,j2scontext,value)
# ORIGINAL # ORIGINAL
# neg_set += r'regexpcountuniquematches("(?:\b)%s(?:\b)",j2s(prev,middle,next))*%s - ' % (key,value) # neg_set += r'regexpcountuniquematches("(?:\b)%s(?:\b)",j2s(prev,middle,next))*%s - ' % (key,value)
data['negwords'].append(key) data['negwords'].append(key)
@ -1245,7 +1247,9 @@ class RunMiningHandler(BaseHandler):
if 'stopwords' in mining_parameters and mining_parameters['stopwords'] == "1": if 'stopwords' in mining_parameters and mining_parameters['stopwords'] == "1":
doc_filters = 'filterstopwords('+doc_filters+')' doc_filters = 'filterstopwords('+doc_filters+')'
ackn_filters = 'filterstopwords('+ackn_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)) 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) 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) cursor.execute(query_pre_grants)
@ -1261,9 +1265,13 @@ class RunMiningHandler(BaseHandler):
# string concatenation workaround because of the special characters conflicts # string concatenation workaround because of the special characters conflicts
if 'wordssplitnum' in mining_parameters and mining_parameters['wordssplitnum'] != '': if 'wordssplitnum' in mining_parameters and mining_parameters['wordssplitnum'] != '':
words_split = int(mining_parameters['wordssplitnum']) words_split = int(mining_parameters['wordssplitnum'])
# TODO must correct this!!!
words_split = words_split + 1
gt2 = 'gt2' gt2 = 'gt2'
if 'lowercase' in mining_parameters and mining_parameters['lowercase'] == "1": if 'lowercase' in mining_parameters and mining_parameters['lowercase'] == "1":
gt2 = 'lower('+gt2+')' gt2 = 'lower('+gt2+')'
if 'stemming' in mining_parameters and mining_parameters['stemming'] == "1":
gt2 = 'stem('+gt2+')'
# MONO GIA TO EGI # MONO GIA TO EGI
if 0 < words_split and words_split <= 20: if 0 < words_split and words_split <= 20:
acknowledgment_split = r'textwindow2s('+gt2+',0,'+str(words_split)+r',0)' acknowledgment_split = r'textwindow2s('+gt2+',0,'+str(words_split)+r',0)'
@ -1371,14 +1379,16 @@ class PrepareSavedProfileHandler(BaseHandler):
filters['contextprev'] = profile_parameters['contextprev'] filters['contextprev'] = profile_parameters['contextprev']
if 'contextnext' in profile_parameters and profile_parameters['contextnext'] != '': if 'contextnext' in profile_parameters and profile_parameters['contextnext'] != '':
filters['contextnext'] = profile_parameters['contextnext'] filters['contextnext'] = profile_parameters['contextnext']
if 'lettercase' in profile_parameters and profile_parameters['lettercase'] != '': if 'lowercase' in profile_parameters and profile_parameters['lowercase'] != '':
filters['lettercase'] = profile_parameters['lettercase'] filters['lowercase'] = profile_parameters['lowercase']
if 'wordssplitnum' in profile_parameters and profile_parameters['wordssplitnum'] != '': if 'wordssplitnum' in profile_parameters and profile_parameters['wordssplitnum'] != '':
filters['wordssplitnum'] = profile_parameters['wordssplitnum'] filters['wordssplitnum'] = profile_parameters['wordssplitnum']
if 'stopwords' in profile_parameters and profile_parameters['stopwords'] != '': if 'stopwords' in profile_parameters and profile_parameters['stopwords'] != '':
filters['stopwords'] = 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'] 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(?,?)", cursor.executemany("insert into filters(c1,c2) values(?,?)",
( (
(key, value,) for key, value in filters.iteritems() (key, value,) for key, value in filters.iteritems()
@ -1452,7 +1462,7 @@ class SaveProfileToDatabaseHandler(BaseHandler):
cursor=madis.functions.Connection(database_file_name).cursor() cursor=madis.functions.Connection(database_file_name).cursor()
user_profiles = [] user_profiles = []
if old_profile: 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: 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) 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) cursor.execute(query, parse=False)