The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

TM::Corpus::SearchAble - Topic Maps, Abstract Trait for searching

SYNOPSIS

use TM;
my $tm = ....                               # get map from somewhere

use TM::Corpus;                             # see this package
my $co = new TM::Corpus (map => $tm)        # bind map with document repository
         ->update                           # mandatory
         ->harvest;                         # optional

                                            # attach searchable behaviour
Class::Trait->apply ($co => 'TM::Corpus::SearchAble::SomeImplementation');
$co->directory ('/where/store/index/');
$co->index;                                 # build index

warn Dumper $co->search ('content:"BBB"');  # search for something

# if you already have an indexed corpus, then
my $co = ....
Class::Trait->apply ($co => 'TM::Corpus::SearchAble::SomeImplementation');
$co->directory ('/where/index/is/stored/');

warn Dumper $co->search ('content:"BBB"');  # search for something

DESCRIPTION

This package is only abstract and it defines the minimal interface a trait which provides search functionality has to honor.

INTERFACE

index

$co->index (...)

This method creates an index. Individual implementations may need additional parameters. The method returns the object itself.

@results = @{ $co->search ($phrase) }

This method takes a search phrase as input and delivers a list (reference) of results. Individual implementations will have special syntaxes for the search phrase, but they have to honor the following fields:

content (tokenized): the content of the referred documents, any names or the values of occurrences (if they are not URIs)
ref (tokenized): the URI references in occurrences
tid (as-is): the toplet identifier where the value is attached
aid (as-is): the assertion identifier where the value is part of

Each result entry is a list (reference) containing (in sequence):

aid: assertion identifier
tid: local toplet identifier (to which that assertion belongs)
baseuri: the baseuri of the map

COPYRIGHT AND LICENSE

Copyright 200[8] by Robert Barta, <drrho@cpan.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.