Compare commits
No commits in common. "master" and "master" have entirely different histories.
@ -1,87 +0,0 @@
|
||||
6
|
||||
5
|
||||
7
|
||||
8
|
||||
13
|
||||
10
|
||||
15
|
||||
14
|
||||
10
|
||||
7
|
||||
14
|
||||
10
|
||||
5
|
||||
19
|
||||
0
|
||||
0
|
||||
0
|
||||
13
|
||||
3
|
||||
19
|
||||
2
|
||||
12
|
||||
16
|
||||
2
|
||||
14
|
||||
12
|
||||
1
|
||||
16
|
||||
11
|
||||
5
|
||||
15
|
||||
15
|
||||
9
|
||||
18
|
||||
0
|
||||
4
|
||||
5
|
||||
6
|
||||
1
|
||||
8
|
||||
10
|
||||
17
|
||||
4
|
||||
8
|
||||
6
|
||||
3
|
||||
4
|
||||
5
|
||||
9
|
||||
9
|
||||
14
|
||||
7
|
||||
15
|
||||
12
|
||||
17
|
||||
2
|
||||
5
|
||||
5
|
||||
15
|
||||
18
|
||||
4
|
||||
5
|
||||
15
|
||||
13
|
||||
10
|
||||
18
|
||||
15
|
||||
6
|
||||
7
|
||||
4
|
||||
13
|
||||
3
|
||||
6
|
||||
15
|
||||
5
|
||||
14
|
||||
14
|
||||
17
|
||||
8
|
||||
19
|
||||
7
|
||||
14
|
||||
7
|
||||
19
|
||||
15
|
||||
18
|
||||
19
|
|
41
solution.py
41
solution.py
@ -1,41 +0,0 @@
|
||||
from sklearn.feature_extraction.text import TfidfVectorizer
|
||||
import numpy as np
|
||||
import sklearn.metrics
|
||||
from sklearn.cluster import KMeans
|
||||
|
||||
# Lista z https://github.com/bieli/stopwords/blob/master/polish.stopwords.txt
|
||||
def remove_stop_words(document, stopwords):
|
||||
return " ".join([word for word in document.split() if word not in stopwords])
|
||||
|
||||
def write_predictions_to_file(predictions, file):
|
||||
with open(file, "w") as out_file:
|
||||
for prediction in predictions:
|
||||
out_file.write(str(prediction) + '\n')
|
||||
|
||||
def load_stop_words():
|
||||
with open('stopwords.txt') as stopwords_file:
|
||||
stopwords = []
|
||||
for stopword in stopwords_file.readlines():
|
||||
# Remove whitespaces from words, to remove all stop words
|
||||
stopwords.append(stopword.strip())
|
||||
return stopwords
|
||||
|
||||
def load_tsv_file(file):
|
||||
stopwords = load_stop_words()
|
||||
with open(file) as in_file:
|
||||
documents = []
|
||||
for document in in_file.readlines():
|
||||
documents.append(remove_stop_words(document, stopwords))
|
||||
return documents
|
||||
|
||||
def prepare_prediction(catalog):
|
||||
documents = load_tsv_file(catalog + "/in.tsv")
|
||||
document_vectors = TfidfVectorizer().fit_transform(documents)
|
||||
|
||||
# Z n_clusters w okolicy 20 uzyskiwałem wyniki pokroju 0.85 (według Geval). Jednakże, z n_clusters 50 wyniki było
|
||||
# przy każdym uruchomieniu zbliżone do siebie. Przy n = 20 wachają się od 0.7 do 0.85
|
||||
predictions = KMeans(n_clusters=20, max_iter=1000).fit_predict(document_vectors)
|
||||
write_predictions_to_file(predictions, catalog + "/out.tsv")
|
||||
|
||||
prepare_prediction("dev-0")
|
||||
prepare_prediction("test-A")
|
350
stopwords.txt
350
stopwords.txt
@ -1,350 +0,0 @@
|
||||
a
|
||||
aby
|
||||
ach
|
||||
acz
|
||||
aczkolwiek
|
||||
aj
|
||||
albo
|
||||
ale
|
||||
alez
|
||||
ależ
|
||||
ani
|
||||
az
|
||||
aż
|
||||
bardziej
|
||||
bardzo
|
||||
beda
|
||||
bedzie
|
||||
bez
|
||||
deda
|
||||
będą
|
||||
bede
|
||||
będę
|
||||
będzie
|
||||
bo
|
||||
bowiem
|
||||
by
|
||||
byc
|
||||
być
|
||||
byl
|
||||
byla
|
||||
byli
|
||||
bylo
|
||||
byly
|
||||
był
|
||||
była
|
||||
było
|
||||
były
|
||||
bynajmniej
|
||||
cala
|
||||
cali
|
||||
caly
|
||||
cała
|
||||
cały
|
||||
ci
|
||||
cie
|
||||
ciebie
|
||||
cię
|
||||
co
|
||||
cokolwiek
|
||||
cos
|
||||
coś
|
||||
czasami
|
||||
czasem
|
||||
czemu
|
||||
czy
|
||||
czyli
|
||||
daleko
|
||||
dla
|
||||
dlaczego
|
||||
dlatego
|
||||
do
|
||||
dobrze
|
||||
dokad
|
||||
dokąd
|
||||
dosc
|
||||
dość
|
||||
duzo
|
||||
dużo
|
||||
dwa
|
||||
dwaj
|
||||
dwie
|
||||
dwoje
|
||||
dzis
|
||||
dzisiaj
|
||||
dziś
|
||||
gdy
|
||||
gdyby
|
||||
gdyz
|
||||
gdyż
|
||||
gdzie
|
||||
gdziekolwiek
|
||||
gdzies
|
||||
gdzieś
|
||||
go
|
||||
i
|
||||
ich
|
||||
ile
|
||||
im
|
||||
inna
|
||||
inne
|
||||
inny
|
||||
innych
|
||||
iz
|
||||
iż
|
||||
ja
|
||||
jak
|
||||
jakas
|
||||
jakaś
|
||||
jakby
|
||||
jaki
|
||||
jakichs
|
||||
jakichś
|
||||
jakie
|
||||
jakis
|
||||
jakiś
|
||||
jakiz
|
||||
jakiż
|
||||
jakkolwiek
|
||||
jako
|
||||
jakos
|
||||
jakoś
|
||||
ją
|
||||
je
|
||||
jeden
|
||||
jedna
|
||||
jednak
|
||||
jednakze
|
||||
jednakże
|
||||
jedno
|
||||
jego
|
||||
jej
|
||||
jemu
|
||||
jesli
|
||||
jest
|
||||
jestem
|
||||
jeszcze
|
||||
jeśli
|
||||
jezeli
|
||||
jeżeli
|
||||
juz
|
||||
już
|
||||
kazdy
|
||||
każdy
|
||||
kiedy
|
||||
kilka
|
||||
kims
|
||||
kimś
|
||||
kto
|
||||
ktokolwiek
|
||||
ktora
|
||||
ktore
|
||||
ktorego
|
||||
ktorej
|
||||
ktory
|
||||
ktorych
|
||||
ktorym
|
||||
ktorzy
|
||||
ktos
|
||||
ktoś
|
||||
która
|
||||
które
|
||||
którego
|
||||
której
|
||||
który
|
||||
których
|
||||
którym
|
||||
którzy
|
||||
ku
|
||||
lat
|
||||
lecz
|
||||
lub
|
||||
ma
|
||||