Skip to content
Snippets Groups Projects
Commit 4da9d343 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Added the Resultpage for associations

parent 03a7f340
No related branches found
No related tags found
1 merge request!1308Resolve "Redesign the Assoziator"
......@@ -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));
}
......
......@@ -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
......@@ -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');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment