Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MetaGer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
open-source
MetaGer
Commits
64780f51
Commit
64780f51
authored
6 years ago
by
Dominik Hebeler
Browse files
Options
Downloads
Patches
Plain Diff
Removed Catpcha from Assoziator
parent
bcd6c2bd
No related branches found
No related tags found
1 merge request
!1365
Resolve "Filter Options for MetaGer"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/Http/Controllers/Assoziator.php
+22
-22
22 additions, 22 deletions
app/Http/Controllers/Assoziator.php
with
22 additions
and
22 deletions
app/Http/Controllers/Assoziator.php
+
22
−
22
View file @
64780f51
...
...
@@ -7,13 +7,14 @@ use LaravelLocalization;
class
Assoziator
extends
Controller
{
public
function
asso
(
Request
$request
){
public
function
asso
(
Request
$request
)
{
$eingabe
=
$request
->
input
(
'q'
,
''
);
if
(
empty
(
$eingabe
)){
if
(
empty
(
$eingabe
))
{
return
redirect
(
LaravelLocalization
::
getLocalizedURL
(
LaravelLocalization
::
getCurrentLocale
(),
'/asso'
));
}
$url
=
"https://metager.de/meta/meta.ger3?eingabe="
.
urlencode
(
$eingabe
)
.
"&out=atom10"
;
$url
=
"https://metager.de/meta/meta.ger3?eingabe="
.
urlencode
(
$eingabe
)
.
"&out=atom10
&key=test
"
;
$ch
=
curl_init
();
...
...
@@ -28,26 +29,24 @@ class Assoziator extends Controller
CURLOPT_TIMEOUT
=>
10
,
CURLOPT_URL
=>
$url
,
CURLOPT_HTTPHEADER
,
array
(
"X_FORWARDED_FOR: "
.
$request
->
ip
()
)
"X_FORWARDED_FOR: "
.
$request
->
ip
()
,
)
,
));
$response
=
curl_exec
(
$ch
);
$responseCode
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
curl_close
(
$ch
);
if
(
$responseCode
!==
200
)
if
(
$responseCode
!==
200
)
{
abort
(
500
,
"Server currently not available"
);
}
$response
=
preg_replace
(
"/^<\?.*\?>/s"
,
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>"
,
$response
);
$content
=
simplexml_load_string
(
$response
);
$words
=
[];
foreach
(
$content
->
entry
as
$entry
){
foreach
(
$content
->
entry
as
$entry
)
{
#
$title = $entry->title->__toString();
$content
=
$entry
->
content
->
__toString
();
...
...
@@ -58,32 +57,31 @@ class Assoziator extends Controller
$n_words
=
preg_match_all
(
'/([a-zA-Z]|\xC3[\x80-\x96\x98-\xB6\xB8-\xBF]|\xC5[\x92\x93\xA0\xA1\xB8\xBD\xBE]){2,}/'
,
$content
,
$match_arr
);
$wordsTmp
=
array_merge
(
$wordsTmp
,
$match_arr
[
0
]);
#
#
foreach
(
$wordsTmp
as
$word
){
if
(
isset
(
$words
[
$word
])){
foreach
(
$wordsTmp
as
$word
)
{
if
(
isset
(
$words
[
$word
]))
{
$words
[
$word
]
++
;
}
else
if
(
isset
(
$words
[
ucfirst
(
$word
)])){
}
else
if
(
isset
(
$words
[
ucfirst
(
$word
)]))
{
$words
[
ucfirst
(
$word
)]
++
;
}
else
if
(
isset
(
$words
[
strtolower
(
$word
)])){
}
else
if
(
isset
(
$words
[
strtolower
(
$word
)]))
{
$words
[
strtolower
(
$word
)]
++
;
}
else
{
}
else
{
$words
[
$word
]
=
1
;
}
}
}
arsort
(
$words
);
$eingabeWords
=
explode
(
" "
,
$eingabe
);
foreach
(
$eingabeWords
as
$eingabeWord
){
foreach
(
$eingabeWords
as
$eingabeWord
)
{
unset
(
$words
[
$eingabeWord
]);
unset
(
$words
[
strtolower
(
$eingabeWord
)]);
unset
(
$words
[
ucfirst
(
$eingabeWord
)]);
unset
(
$words
[
strtoupper
(
$eingabeWord
)]);
}
unset
(
$words
[
"de"
]);
unset
(
$words
[
"com"
]);
unset
(
$words
[
"wiki"
]);
...
...
@@ -92,7 +90,7 @@ class Assoziator extends Controller
// Remove Stopwords
$stopWords
=
file
(
storage_path
(
'app/public/stopwords.txt'
));
foreach
(
$stopWords
as
$stopWord
){
foreach
(
$stopWords
as
$stopWord
)
{
$stopWord
=
trim
(
$stopWord
);
unset
(
$words
[
$stopWord
]);
unset
(
$words
[
strtolower
(
$stopWord
)]);
...
...
@@ -103,9 +101,11 @@ class Assoziator extends Controller
$i
=
1
;
$max
=
60
;
foreach
(
$words
as
$key
=>
$value
){
if
(
$i
>
$max
)
foreach
(
$words
as
$key
=>
$value
)
{
if
(
$i
>
$max
)
{
unset
(
$words
[
$key
]);
}
$wordCount
+=
$value
;
$i
++
;
}
...
...
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