blob: a34a573761105e957b77d8ec632c30acb6f29a45 [file] [log] [blame]
Akrone23e2922017-05-01 13:18:12 +02001package Krawfish::Result::Group::Spans;
2use parent 'Krawfish::Result';
3use Krawfish::Log;
4use Krawfish::Posting::Match;
5use strict;
6use warnings;
7
8# This may be genralizable, but for the moment
9# It should make it possible to group the span positions
10# of a query based on a nesting query.
11#
12# The idea is to make the following possible:
13# Search for a term in sentences (like "{1:contains(<s>, {2:'baum'})}") and
14# based on the position and length of 1 and 2,
15# a result like
16#
17# 0: 5
18# 1: 7
19# 100: 2
20#
21# can be returned, where each class 1 is sliced in
22# 100 pieces and for each pieces there is a dot, in case
23# class 2 occurs in that slice.
24#
25# By doing that it's easy to visualize the position of expressions
26# in sentences or documents etc.
27#
28# For example to answer questions like (where in documents does
29# the phrase "Herzlichen Dank" occur.
30#
31# If the span spans more than 1 slice, the result can be
32#
33# 0_2: 1
34# 0_3: 4
35# 4: 6
36#
37# etc. In case the second class is not nested in the first
38# class, this is not counted at all (as this would result
39# in weird data regarding the slice sizes).
40
41sub new {
42 my $class = shift;
43 my %param = @_;
44 bless {
45 slices => $param{slices} // 100,
46 wrap_clas => $param{wrap_class} // 1,
47 embedded_class => $param{embedded_class} // 2
48 }, $class;
49};
50
51# Get the group signature for each match
52# May well be renamed to get_signature
53sub get_group {
54 my $self = shift;
55 my $slice_start = 0;
56 my $slice_end = 0;
57 return $slice_start . '_' . $slice_end;
58};
59
601;