NAME

DDC::Format::Kwic - Keyword-in-context (KWIC) formatting for DDC hits

SYNOPSIS

 use DDC::Concordance;

 $hitList = DDC::Client::Distributed->new()->query('foo&&bar'); ##-- get some hits

 $fmt  = DDC::Format::Kwic->new(width=>$nchars);
 $str = $fmt->toString($hitList);        ##-- conversion to string
 $fmt->toFile($hitList,$filename);       ##-- output to file
 $fmt->toFh($hitList,$fh);               ##-- output to filehandle

DESCRIPTION

Class for formatting DDC::Hit objects as keyword-in-context (KWIC) lines.

Globals

Variable: @ISA

DDC::Format::Kwic inherits from DDC::Format.

Constructors, etc.

new
 $fmt = $CLASS_OR_OBJ->new(%args);

Accepted keywords in %args:

  start       => $previous_hit_num, ##-- pre-initial hit number (default=0)
  highlight   => [$pre,$post],      ##-- highlighting substrings (default=['__','__'])
  width       => $nchars,           ##-- context width; default=32
  useMatchIds => $bool,             ##-- whether to use match-ids if available; undef (default) if non-trivial match-ids are specified
reset
 $fmt = $fmt->reset();

Resets the formatting object.

Helper functions

hitString
 $hitStr = $fmt->hitString($hit);

Formats a single $hit as a string, incrementing the counter $fmt->{start} as a side-effect.

API

toString
 $str = $fmt->toString($hitList);

Implements DDC::Format::toString().

AUTHOR

Bryan Jurish <moocow@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2014-2016 by Bryan Jurish

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.