Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
chaos_familien_duell_frontend
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mowoe
chaos_familien_duell_frontend
Commits
a58a6c34
Commit
a58a6c34
authored
6 years ago
by
Leonhard Strohmidel
Browse files
Options
Downloads
Patches
Plain Diff
~further changes
parent
31b0dbf6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
evaluation.py
+34
-4
34 additions, 4 deletions
evaluation.py
model/__init__.py
+2
-2
2 additions, 2 deletions
model/__init__.py
with
36 additions
and
6 deletions
evaluation.py
+
34
−
4
View file @
a58a6c34
from
model
import
*
from
peewee
import
fn
import
json
from
difflib
import
SequenceMatcher
punctuation
=
[
'
!
'
,
'
?
'
,
'
.
'
,
'
,
'
,
'
;
'
,
'
:
'
,
'
-
'
,
'
_
'
,
'"'
,
"'"
,
'
…
'
,
'
—
'
,
'
#
'
,
'
@
'
]
semantic
=
[
'
e.v.
'
,
'
ev
'
,
'
ev.
'
,
'
e.v
'
,
'
herr
'
,
'
hr
'
,
'
frau
'
,
'
fr
'
,
'
ag
'
,
'
gmbh
'
,
'
& co kg
'
]
semantic
=
[
'
e.v.
'
,
'
ev.
'
,
'
e.v
'
,
'
ev
'
,
'
herr
'
,
'
hr
'
,
'
frau
'
,
'
fr
'
,
'
ag
'
,
'
gmbh
'
,
'
& co kg
'
,
'
dr.
'
,
'
dr
'
]
def
remove_punctuation
(
text
):
for
char
in
punctuation
:
...
...
@@ -16,9 +18,9 @@ def remove_semantics(text):
return
text
def
replace_umlautes
(
text
):
text
=
text
.
replace
(
"
oe
"
,
"
ö
"
)
text
=
text
.
replace
(
"
ö
"
,
"
oe
"
)
text
=
text
.
replace
(
"
ß
"
,
"
ss
"
)
text
=
text
.
replace
(
"
ae
"
,
"
ä
"
)
text
=
text
.
replace
(
"
ä
"
,
"
ae
"
)
text
=
text
.
replace
(
"
ue
"
,
"
ü
"
)
return
text
...
...
@@ -62,7 +64,35 @@ def update_answer_from_file():
jzon
=
json
.
load
(
file
)
update_answer_text_batch
(
jzon
)
def
generate_answer_classes
():
def
generate_answer_classes
(
treshhold
):
questions
=
Question
.
select
()
for
q
in
questions
:
answers
=
Answer
.
select
().
where
(
Answer
.
question
==
q
)
answer_list
=
[]
for
a
in
answers
:
answer_list
.
append
(
a
)
length
=
len
(
answer_list
)
classes
=
[]
for
i
in
range
(
length
):
answer
=
answer_list
[
i
]
if
answer
is
None
:
continue
current_class
=
[
answer
.
text
]
for
j
in
range
(
i
+
1
,
length
):
bnswer
=
answer_list
[
j
]
if
bnswer
is
None
:
continue
r
=
SequenceMatcher
(
None
,
answer
.
text
,
bnswer
.
text
).
ratio
()
if
r
>
treshhold
:
current_class
.
append
(
bnswer
.
text
)
answer_list
[
j
]
=
None
current_class
=
list
(
set
(
current_class
))
current_class
=
sorted
(
current_class
)
classes
.
append
(
current_class
)
with
open
(
"
q%d-classes.json
"
%
q
.
id
,
"
w
"
)
as
file
:
json
.
dump
(
classes
,
file
,
indent
=
4
,
sort_keys
=
True
)
def
aggregate_answer_file
():
...
...
This diff is collapsed.
Click to expand it.
model/__init__.py
+
2
−
2
View file @
a58a6c34
...
...
@@ -3,9 +3,9 @@ from peewee import Model
from
peewee
import
MySQLDatabase
import
json
mysql_creds
=
json
.
load
(
open
(
"
./creds.json
"
))
#
mysql_creds = json.load(open("./creds.json"))
sqlite
=
SqliteDatabase
(
"
cfd.sqlite
"
,
pragmas
=
{
'
foreign_keys
'
:
1
})
sqlite
=
SqliteDatabase
(
"
model/
cfd.sqlite
"
,
pragmas
=
{
'
foreign_keys
'
:
1
})
sqlite
.
connect
()
#sqlite = MySQLDatabase(mysql_creds["db"], user=mysql_creds["user"], password=mysql_creds['password'],
# host=mysql_creds['host'], port=int(mysql_creds['port']),)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment