|
|
@@ -7,6 +7,7 @@ from subprocess import * |
|
|
|
from threading import Thread |
|
|
|
import time |
|
|
|
from UIModell import * |
|
|
|
import re |
|
|
|
|
|
|
|
class ModellTaktil(Modell): |
|
|
|
|
|
|
@@ -62,7 +63,7 @@ class ModellTaktil(Modell): |
|
|
|
while True: |
|
|
|
output = process.stdout.readline() |
|
|
|
print(output.strip()) |
|
|
|
x = output.find("schlagwort?") |
|
|
|
x = output.find("Application terminated") |
|
|
|
y = output.find("Error") |
|
|
|
if(x != -1): |
|
|
|
print("Training finished") |
|
|
@@ -82,16 +83,18 @@ class ModellTaktil(Modell): |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
self.controller.stop() |
|
|
|
#self.controller.stop() |
|
|
|
|
|
|
|
def trainXDawn(self): |
|
|
|
'''-------------------------------------------------------------------------------------------------- |
|
|
|
Holt aus der shared Library die Befehle und startet das XDawnTraining. Reagiert auf Error oder |
|
|
|
die Ausgabe das das Training beendet wurde. Bei Beenden startet es das ClassifierTraining, bei Error wird der Vorgang gestoppt. |
|
|
|
''' |
|
|
|
print("start training Xdawn") |
|
|
|
print("Start training Xdawn") |
|
|
|
self.controller.addInfoText('Starten des xDawn-Trainings -- ') |
|
|
|
command = self.dll.getCommandXDawn_taktil().split(" ") |
|
|
|
command = self.dll.getCommandXDawn_taktil() #.split(" ") |
|
|
|
print("Command: " + command) |
|
|
|
command = command.split(" ") |
|
|
|
process = Popen(command, stdout=PIPE, universal_newlines=True) |
|
|
|
|
|
|
|
self.openVibeAktiv = True |
|
|
@@ -117,7 +120,7 @@ class ModellTaktil(Modell): |
|
|
|
print("stop") |
|
|
|
break |
|
|
|
|
|
|
|
self.controller.stop() |
|
|
|
#self.controller.stop() |
|
|
|
|
|
|
|
#self.controller.filterClassic() |
|
|
|
|
|
|
@@ -134,19 +137,20 @@ class ModellTaktil(Modell): |
|
|
|
process = Popen(command, stdout=PIPE, universal_newlines=True) |
|
|
|
|
|
|
|
self.openVibeAktiv = True |
|
|
|
counter = 0 |
|
|
|
counter = 0 |
|
|
|
acc = 0 |
|
|
|
while True: |
|
|
|
output = process.stdout.readline() |
|
|
|
print(output.strip()) |
|
|
|
x = output.find("aka Classifier trainer") |
|
|
|
accuracy = output.find("Training set accuracy is") |
|
|
|
accuracy = output.find("Cross-validation test accuracy is ") |
|
|
|
y = output.find("Error") |
|
|
|
if(x != -1): |
|
|
|
counter = counter +1 |
|
|
|
#counter = 18 |
|
|
|
if(counter >= 17): |
|
|
|
print("Training finished") |
|
|
|
self.controller.addInfoText('Training beendet\n') |
|
|
|
self.controller.addInfoText('Training beendet (' + acc + ')\n') |
|
|
|
process.terminate() |
|
|
|
self.controller.stop("save") |
|
|
|
break |
|
|
@@ -156,8 +160,18 @@ class ModellTaktil(Modell): |
|
|
|
self.controller.addInfoText("Fehler beim Classifier Training aufgetaucht\n") |
|
|
|
process.terminate() |
|
|
|
break |
|
|
|
elif(accuracy != -1): |
|
|
|
print("ACCURACY" + output) |
|
|
|
if(accuracy != -1): |
|
|
|
#print("Output:") |
|
|
|
#print(output) |
|
|
|
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])') |
|
|
|
test = output.encode("windows-1252").decode("utf-8") |
|
|
|
i = len("Cross-validation test") |
|
|
|
#print(output[accuracy:accuracy+i+12]) |
|
|
|
#print(test[accuracy+i+12:accuracy+i+40].strip()) |
|
|
|
acc_s = test[accuracy+i:accuracy+i+41].strip() |
|
|
|
acc = ansi_escape.sub('', acc_s) |
|
|
|
print(acc) |
|
|
|
|
|
|
|
if not self.aktiv: |
|
|
|
print("stop") |
|
|
|
break |
|
|
@@ -180,7 +194,7 @@ class ModellTaktil(Modell): |
|
|
|
output = process.stdout.readline() |
|
|
|
print(output.strip()) |
|
|
|
y = output.find("Error") |
|
|
|
x = output.find("Schlagwort") |
|
|
|
x = output.find("Application terminated") |
|
|
|
if(x != -1): |
|
|
|
print("End Spelling") |
|
|
|
process.terminate() |