blob: b8972a0110055f328b6b0877f2d916f8fdfedad7 [file] [log] [blame]
Nils Diewald5d1ffb42014-05-21 17:45:34 +00001package Korap::Search;
2use Mojo::Base 'Mojolicious::Controller';
3
4# This action will render a template
5sub remote {
6 my $c = shift;
Nils Diewald2329e1d2014-06-12 16:07:57 +00007 $c->layout('default');
8 $c->title('KorAP');
Nils Diewald5d1ffb42014-05-21 17:45:34 +00009
Nils Diewald2329e1d2014-06-12 16:07:57 +000010 if ((scalar $c->param('action') // '') eq 'inspect') {
Nils Diewald02df9912014-06-03 16:08:07 +000011 my $api = $c->config('KorAP')->{api};
12 my $url = Mojo::URL->new($api)->path('resource/query');
Nils Diewald33e15552014-06-13 19:38:37 +000013
Nils Diewald02df9912014-06-03 16:08:07 +000014 $url->query({
15 q => scalar $c->param('q') // '',
16 ql => scalar $c->param('ql') // 'poliqarp'
17 });
Nils Diewald33e15552014-06-13 19:38:37 +000018
Nils Diewald02df9912014-06-03 16:08:07 +000019 if (my $response = $c->ua->get($url)->success) {
20 $c->stash('search.query' => $response->json);
21 }
22 else {
23 $c->notify(error => 'Unable to retrieve serialized query');
24 };
25
26 $c->param(cutoff => 1);
Nils Diewald2329e1d2014-06-12 16:07:57 +000027 return $c->render(template => 'query');
28 }
29
30 elsif ($c->param('snippet')) {
31 $c->layout('snippet');
Nils Diewald02df9912014-06-03 16:08:07 +000032 };
33
Nils Diewald5d1ffb42014-05-21 17:45:34 +000034 $c->render(template => 'search');
35};
36
Nils Diewald02df9912014-06-03 16:08:07 +000037sub info {
38 my $c = shift;
39 my $api = $c->config('KorAP')->{api};
40 my $src = $c->stash('resource');
Nils Diewald2329e1d2014-06-12 16:07:57 +000041 $c->render(json => $c->notifications(json => $c->info_on($src)));
Nils Diewald02df9912014-06-03 16:08:07 +000042};
Nils Diewald5d1ffb42014-05-21 17:45:34 +000043
Nils Diewald2329e1d2014-06-12 16:07:57 +000044
Nils Diewald5d1ffb42014-05-21 17:45:34 +0000451;
Nils Diewald02df9912014-06-03 16:08:07 +000046
47
48__END__
49
Nils Diewald2329e1d2014-06-12 16:07:57 +000050[{"shared":false,"id":1,"managed":true,"created":1401193381119,"stats":{"documents":196510,"tokens":51545081,"sentences":4116282,"paragraphs":2034752},"query":[{"@type":"korap:meta-filter","@value":{"@type":"korap:term","@field":"korap:field#corpusID","@value":"WPD"}}],"description":"Die freie Enzyklopädie","name":"Wikipedia","foundries":"base;corenlp;mate;mpt;opennlp;tt;xip"}]
Nils Diewald33e15552014-06-13 19:38:37 +000051
52
53
54
55
56http://10.0.10.13:8070/api/v1/resource/matchInfo?id=match-WPD!WPD_NNN.02848-p1223-1224&f=mate&l=
57
58{"author":"Filzstift,Alexander Sommer,TheK","textClass":"freizeit-unterhaltung reisen","corpusID":"WPD","title":"Neuseeland","foundries":"xip xip/morpho xip/constituency xip/dependency corenlp corenlp/namedentities corenlp/namedentities/ne_dewac_175m_600 corenlp/namedentities corenlp/namedentities/ne_hgc_175m_600 mate mate/morpho mate/dependency connexor connexor/morpho connexor/syntax connexor/phrase treetagger treetagger/morpho base base/sentences base/paragraphs opennlp opennlp/morpho","tokenization":"opennlp#tokens","field":"tokens","startMore":false,"endMore":false,"docID":"WPD_NNN.02848","snippet":"<span class=\"context-left\"></span><span class=\"match\"><span title=\"mate/l:besonders\"><span title=\"mate/p:ADV\">Besonders</span></span> <span title=\"mate/l:auffällig\"><span title=\"mate/m:degree:pos\"><span title=\"mate/p:ADJD\">auffällig</span></span></span> <span title=\"mate/l:sein\"><span title=\"mate/m:mood:ind\"><span title=\"mate/m:number:pl\"><span title=\"mate/m:person:3\"><span title=\"mate/m:tense:pres\"><span title=\"mate/p:VAFIN\">sind</span></span></span></span></span></span> <span title=\"mate/l:schließlich\"><span title=\"mate/p:ADV\">schließlich</span></span> <span title=\"mate/l:noch\"><span title=\"mate/p:ADV\">noch</span></span> <span title=\"mate/l:der\"><span title=\"mate/m:case:nom\"><span title=\"mate/m:gender:masc\"><span title=\"mate/m:number:sg\"><span title=\"mate/p:ART\">der</span></span></span></span></span> <span title=\"mate/l:pohutukawa\"><span title=\"mate/m:case:nom\"><span title=\"mate/m:gender:masc\"><span title=\"mate/m:number:sg\"><span title=\"mate/p:NE\">Pohutukawa</span></span></span></span></span> <span title=\"mate/l:und\"><span title=\"mate/p:KON\">und</span></span> <span title=\"mate/l:der\"><span title=\"mate/m:case:nom\"><span title=\"mate/m:gender:masc\"><span title=\"mate/m:number:sg\"><span title=\"mate/p:ART\">der</span></span></span></span></span> <span title=\"mate/l:cabbage\"><span title=\"mate/m:case:nom\"><span title=\"mate/m:gender:masc\"><span title=\"mate/m:number:sg\"><span title=\"mate/p:NE\">Cabbage</span></span></span></span></span> <span title=\"mate/l:tree\"><span title=\"mate/m:gender:masc\"><span title=\"mate/m:number:sg\"><span title=\"mate/p:NE\"><span title=\"mate/m:case:nom\">Tree</span></span></span></span></span></span><span class=\"context-right\"></span>","ID":"match-WPD!WPD_NNN.02848-p1213-1224","pubDate":"2005-03-28","context":{"left":["token",0],"right":["token",0]}}