Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Translations
annotation_www
Commits
3bf5ac79
Commit
3bf5ac79
authored
Jan 16, 2014
by
Martin Gregor
Browse files
pridanie lematizacie pomocou sluzby
parent
2ba54991
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/presenters/HomepagePresenter.php
View file @
3bf5ac79
...
...
@@ -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
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment