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
open-source
MetaGer
Commits
4da9d343
Commit
4da9d343
authored
Sep 21, 2018
by
Dominik Hebeler
Browse files
Added the Resultpage for associations
parent
03a7f340
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/Assoziator.php
View file @
4da9d343
...
...
@@ -13,7 +13,6 @@ class Assoziator extends Controller
return
redirect
(
LaravelLocalization
::
getLocalizedURL
(
LaravelLocalization
::
getCurrentLocale
(),
'/asso'
));
}
/*
$url
=
"https://metager.de/meta/meta.ger3?eingabe="
.
urlencode
(
$eingabe
)
.
"&out=atom10"
;
$ch
=
curl_init
();
...
...
@@ -41,12 +40,9 @@ class Assoziator extends Controller
if
(
$responseCode
!==
200
)
abort
(
500
,
"Server currently not available"
);
*/
$response
=
file_get_contents
(
storage_path
(
"app/public/results.xml"
));
$response
=
preg_replace
(
"/^<\?.*\?>/s"
,
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>"
,
$response
);
#die(var_dump($response));
$content
=
simplexml_load_string
(
$response
);
$words
=
[];
...
...
@@ -85,6 +81,8 @@ class Assoziator extends Controller
unset
(
$words
[
ucfirst
(
$eingabe
)]);
unset
(
$words
[
"de"
]);
unset
(
$words
[
"com"
]);
unset
(
$words
[
"wiki"
]);
unset
(
$words
[
"Wiki"
]);
// Remove Stopwords
$stopWords
=
file
(
storage_path
(
'app/public/stopwords.txt'
));
...
...
@@ -96,6 +94,23 @@ class Assoziator extends Controller
unset
(
$words
[
ucfirst
(
$stopWord
)]);
}
$wordCount
=
0
;
$i
=
1
;
$max
=
60
;
foreach
(
$words
as
$key
=>
$value
){
if
(
$i
>
$max
)
unset
(
$words
[
$key
]);
$wordCount
+=
$value
;
$i
++
;
}
return
view
(
'assoziator.asso'
)
->
with
(
'title'
,
trans
(
'titles.asso'
))
->
with
(
'navbarFocus'
,
'dienste'
)
->
with
(
'words'
,
$words
)
->
with
(
'keywords'
,
$eingabe
)
->
with
(
'wordCount'
,
$wordCount
);
die
(
var_dump
(
$words
));
}
...
...
resources/views/assoziator/asso.blade.php
View file @
4da9d343
...
...
@@ -12,11 +12,38 @@
<
div
class
=
"card-heavy"
>
<
p
>
{{
trans
(
'asso.1.1'
)
}}
<
a
href
=
"{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), '/') }}"
target
=
"_blank"
>
{{
trans
(
'asso.1.2'
)
}}
</
a
>.</
p
>
<
form
>
<
form
method
=
"post"
>
<
div
class
=
"input-group"
>
<
input
type
=
"text"
class
=
"form-control"
placeholder
=
"Zu assoziierender Begriff"
name
=
"q"
required
autofocus
/>
<
input
type
=
"text"
class
=
"form-control"
placeholder
=
"Zu assoziierender Begriff"
@
if
(
isset
(
$keywords
))
value
=
"
{
{$keywords}
}
"
@
endif
name
=
"q"
required
autofocus
/>
<
div
class
=
"input-group-addon"
><
button
type
=
"submit"
><
i
class
=
"fa fa-search"
aria
-
hidden
=
"true"
></
i
></
button
></
div
>
</
div
>
</
form
>
</
div
>
@
if
(
isset
(
$words
))
<
div
class
=
"card-heavy"
>
<
div
class
=
"table-responsive"
>
<
table
class
=
"table"
>
<
caption
>
Assoziationen
für
"{{
$keywords
}}"
</
caption
>
<
thead
>
<
tr
>
<
th
>
#</th>
<
th
>
Assoziation
</
th
>
<
th
>
Relevanz
</
th
>
</
tr
>
</
thead
>
<
tbody
>
@
php
$i
=
1
;
@
endphp
@
foreach
(
$words
as
$key
=>
$value
)
<
tr
>
<
td
>
{{
$i
}}
</
td
>
<
td
>
{{
$key
}}
</
td
>
<
td
>
{{
round
((
$value
/
$wordCount
)
*
100
,
2
)
}}
%</
td
>
@
php
$i
++
;
@
endphp
</
tr
>
@
endforeach
</
tbody
>
</
table
>
</
div
>
</
div
>
@
endif
@
endsection
routes/web.php
View file @
4da9d343
...
...
@@ -20,11 +20,12 @@ Route::group(
Route
::
get
(
'/'
,
'StartpageController@loadStartPage'
);
Route
::
get
(
'asso'
,
'Assoziator@asso'
/*
function(){
Route
::
get
(
'asso'
,
function
(){
return
view
(
'assoziator.asso'
)
->
with
(
'title'
,
trans
(
'titles.asso'
))
->
with
(
'navbarFocus'
,
'dienste'
);
}*/
);
});
Route
::
post
(
'asso'
,
'Assoziator@asso'
);
Route
::
get
(
'img/piwik.png'
,
'ImageController@generateImage'
);
...
...
Write
Preview
Markdown
is supported
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