Commit 3bf5ac79 authored by Martin Gregor's avatar Martin Gregor
Browse files

pridanie lematizacie pomocou sluzby

parent 2ba54991
......@@ -13,6 +13,7 @@ class HomepagePresenter extends BasePresenter
private $exchange_count = 2;
private $sentences = [];
private $words = [];
private $words_lema = [];
private $en_words = [];
public function renderDefault()
......@@ -49,10 +50,10 @@ class HomepagePresenter extends BasePresenter
$this->words = explode(' ', $sentence->sentence);
// lematizacia skolskou sluzbou
// $this->lematize($sentence);
$this->lematize($sentence->sentence);
// preklad kazdeho slova z vety
foreach ($this->words as $word)
foreach ($this->words_lema as $word)
{
$this->en_words[] = $this->translate($word);
}
......@@ -243,7 +244,7 @@ class HomepagePresenter extends BasePresenter
}
else
{
$this->db->table('translations')->insert(['sentence_id' => $this->sentence_id,'translation' => $sentence,
$this->db->table('translations')->insert(['sentence_id' => $this->sentence_id,'translation' => $sentence, 'lemas' => implode(' ',$this->words_lema),
'correct_count' => 0, 'incorrect_count' => 0, 'view_count' => 1,
'translated_word_count' => count($this->sentences[$sentence])]);
$translation_id = $this->db->lastInsertId();
......@@ -260,11 +261,11 @@ class HomepagePresenter extends BasePresenter
foreach ($words as $position => $word)
{
$word_en_id = $this->db->table('word_en')->where(['word_en' => $word])->select('id')->fetch();
$word_sk_id = $this->db->table('word_sk')->where(['word_sk' => $this->words[$position]])->select('id')->fetch();
$word_sk_id = $this->db->table('word_sk')->where(['word_sk' => $this->words[$position],'word_lema' => $this->words_lema[$position]])->select('id')->fetch();
if (!$word_en_id)
$word_en_id = $this->db->table('word_en')->insert(['word_en' => $word]);
if (!$word_sk_id)
$word_sk_id = $this->db->table('word_sk')->insert(['word_sk' => $this->words[$position]]);
$word_sk_id = $this->db->table('word_sk')->insert(['word_sk' => $this->words[$position], 'word_lema' => $this->words_lema[$position]]);
$exists = $this->db->table('word_translation')->where(['word_en_id' => $word_en_id->id, 'word_sk_id' => $word_sk_id->id, 'translation_id' => $translation_id])->count('*');
if (!$exists)
......@@ -281,8 +282,9 @@ class HomepagePresenter extends BasePresenter
$curl->headers = [
'Content-Type' => 'text/plain'
];
$result = $curl->post('http://text.fiit.stuba.sk:8080/lematizer/services/lemmatizer/lemmatize/fast',$sentence);
$this->words = explode(' ',$result->body);
$this->words_lema = explode(' ',$result->body);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment