Commit 37585753 authored by Dominik Hebeler's avatar Dominik Hebeler

List of words for the assoziator is getting generated

parent c046a6ca
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use LaravelLocalization;
class Assoziator extends Controller
{
public function asso(Request $request){
$eingabe = $request->input('q', '');
if(empty($eingabe)){
return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), '/asso'));
}
/*
$url = "https://metager.de/meta/meta.ger3?eingabe=" . urlencode($eingabe) . "&out=atom10";
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_USERAGENT => $_SERVER["AGENT"],
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_MAXCONNECTS => 500,
CURLOPT_LOW_SPEED_LIMIT => 500,
CURLOPT_LOW_SPEED_TIME => 5,
CURLOPT_TIMEOUT => 10,
CURLOPT_URL => $url,
CURLOPT_HTTPHEADER, array(
"X_FORWARDED_FOR: " . $request->ip()
)
));
$response = curl_exec($ch);
$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
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 = [];
foreach($content->entry as $entry){
#
$title = $entry->title->__toString();
$content = $entry->content->__toString();
$n_words = preg_match_all('/([a-zA-Z]|\xC3[\x80-\x96\x98-\xB6\xB8-\xBF]|\xC5[\x92\x93\xA0\xA1\xB8\xBD\xBE]){2,}/', $title, $match_arr);
$wordsTmp = $match_arr[0];
$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])){
$words[$word]++;
}else if(isset($words[ucfirst($word)])){
$words[ucfirst($word)]++;
}else if(isset($words[strtolower($word)])){
$words[strtolower($word)]++;
}else{
$words[$word] = 1;
}
}
}
arsort($words);
unset($words[$eingabe]);
unset($words[strtolower($eingabe)]);
unset($words[ucfirst($eingabe)]);
unset($words["de"]);
unset($words["com"]);
// Remove Stopwords
$stopWords = file(storage_path('app/public/stopwords.txt'));
foreach($stopWords as $stopWord){
$stopWord = trim($stopWord);
unset($words[$stopWord]);
unset($words[strtolower($stopWord)]);
unset($words[ucfirst($stopWord)]);
}
die(var_dump($words));
}
}
......@@ -4366,6 +4366,7 @@
"version": "0.0.9",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"inherits": "~2.0.0"
}
......@@ -4390,7 +4391,8 @@
"buffer-shims": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"caseless": {
"version": "0.12.0",
......@@ -4407,12 +4409,14 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"combined-stream": {
"version": "1.0.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"delayed-stream": "~1.0.0"
}
......@@ -4425,17 +4429,20 @@
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"cryptiles": {
"version": "2.0.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"boom": "2.x.x"
}
......@@ -4475,7 +4482,8 @@
"delayed-stream": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"delegates": {
"version": "1.0.0",
......@@ -4507,7 +4515,8 @@
"extsprintf": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"forever-agent": {
"version": "0.6.1",
......@@ -4630,6 +4639,7 @@
"version": "3.1.3",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"boom": "2.x.x",
"cryptiles": "2.x.x",
......@@ -4677,6 +4687,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "1.0.1"
}
......@@ -4690,7 +4701,8 @@
"isarray": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"isstream": {
"version": "0.1.2",
......@@ -4763,12 +4775,14 @@
"mime-db": {
"version": "1.27.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"mime-types": {
"version": "2.1.15",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"mime-db": "1.27.0"
}
......@@ -4844,7 +4858,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"oauth-sign": {
"version": "0.8.2",
......@@ -4902,7 +4917,8 @@
"process-nextick-args": {
"version": "1.0.7",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"punycode": {
"version": "1.4.1",
......@@ -4940,6 +4956,7 @@
"version": "2.2.9",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"buffer-shims": "~1.0.0",
"core-util-is": "~1.0.0",
......@@ -4991,7 +5008,8 @@
"safe-buffer": {
"version": "5.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"semver": {
"version": "5.3.0",
......@@ -5015,6 +5033,7 @@
"version": "1.0.9",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"hoek": "2.x.x"
}
......@@ -5048,6 +5067,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
......@@ -5058,6 +5078,7 @@
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.0.1"
}
......@@ -5086,6 +5107,7 @@
"version": "2.2.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"block-stream": "*",
"fstream": "^1.0.2",
......@@ -5141,7 +5163,8 @@
"util-deprecate": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"uuid": {
"version": "3.0.1",
......
<?php
return [
'head.1' => 'MetaGer Assoziator',
'1.1' => 'Wenn Sie mit Ihren Suchwörtern nicht weiter kommen: Vielleicht fehlen Ihnen die richtigen? Fragen Sie unseren Assoziator: Geben Sie hier einfach ein oder mehrere Wörter ein, zu denen Sie neue oder bessere Begriffe suchen. Versuchen Sie mit den dann gefundenen Wörtern eine neue Suche indem Sie das neue Wort in der Ausgabeseite anklicken. Es gilt unsere',
'1.2' => 'Datenschutzerklärung',
];
\ No newline at end of file
......@@ -22,4 +22,5 @@ return [
'faktencheck' => 'Fakten-Prüfung contra Fake-News',
'jugendschutz' => 'Jugendschutz',
'ad-info' => 'Werbung bei MetaGer',
'asso' => 'Assoziator - MetaGer',
];
@extends('layouts.subPages')
@section('title', $title )
@section('content')
<style>
form div.input-group-addon button {
padding: 9px;
}
</style>
<h1 class="page-title">{{ trans('asso.head.1') }}</h1>
<div class="card-heavy">
<p>{{ trans('asso.1.1') }} <a href="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), '/') }}" target="_blank">{{ trans('asso.1.2') }}</a>.</p>
<form>
<div class="input-group">
<input type="text" class="form-control" placeholder="Zu assoziierender Begriff" 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>
@endsection
......@@ -20,6 +20,12 @@ Route::group(
Route::get('/', 'StartpageController@loadStartPage');
Route::get('asso', 'Assoziator@asso'/*function(){
return view('assoziator.asso')
->with('title', trans('titles.asso'))
->with('navbarFocus', 'dienste');
}*/);
Route::get('img/piwik.png', 'ImageController@generateImage');
Route::get('impressum', function () {
......
This diff is collapsed.
Markdown is supported
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