Aranea::XML::RequestList

CONTENTS


NAME

Aranea::XML::RequestList - object representing the <request_list> of an Aranea XML object


SYNOPSIS


  use Aranea::XML::Aranea;
  use Aranea::XML::RequestList;
 
  my $stdin = new_from_fd IO::Handle(STDIN, "r");
  my $Aranea = Aranea::XML::Aranea->new($stdin);
 
  my $request_list = $Aranea->request_list();
  my $entries = $request_list->entries();
  # arrayref to entries in request list


DESCRIPTION

The RequestList object represents the request_list section of an Aranea XML object. Here is an example:


  <request_list>
    <entry>
      <query>What is the volcano that destroyed the ancient city of Pompeii?</query>
      <score>1</score>
      <constraints>
        <use_backoff>true</use_backoff>
        <pages_to_search>100</pages_to_search>
      </constraints>
    </entry>
    <entry>
      <query>+the +volcano +that +destroyed +the +ancient +city +of +Pompeii</query>
      <score>1</score>
      <constraints>
        <use_backoff>true</use_backoff>
        <pages_to_search>100</pages_to_search>
      </constraints>
    </entry>
  </request_list>

The RequestList object serves as a container for a collection of RequestEntrys. Under normal circumstances, the creation of a RequestList should be handled automatically by the Aranea::XML::Aranea object.


METHODS

new($data)
Constructs a RequestList object given parsed XML data. Note that this method is rarely invoked manually; under typical usage patterns, the constructor of Aranea::XML::Aranea will call this method automatically.

entries([$listref])
Accesses or mutates the collection of RequestEntrys. When called with no arguments, this method returns a listref of RequestEntrys. When called with a single listref, the collection of RequestEntrys is set to the listref.

The typical usage pattern is to iterate over each request and perform some action, e.g.,


  my $request_list = $Aranea->request_list();
  my $entries = $request_list->entries();
 
  for my $request ( @$entries ) {
    # do stuff...
  }

entries_count()
Returns the number of entries in the RequestList. Note that the return value is similiar to that of $#, i.e., -1 for no entries, 0 for one entry, etc.

add_default_exact_query($q)
Adds a new exact query to the RequestList with default parameters. An exact query specifies an unbound variable, e.g., execution of the request ``?x killed Lincoln'' will return a small fragment of text that directly preceeds the exact phrase ``killed Lincoln.''

add_default_inexact_query($q)
Adds a new inexact query to the RequestList with default parameters. An inexact query does not specifies an unbound variable; rather, the surrounding context of the matched keywords is returned.

write_xml($writer)
Writes the XML representation of this RequestList; takes an XML::Writer as its only argument. Note that this method is rarely invoked manually; under typical usage patterns, the write_xml method of Aranea::XML::Aranea will call this method automatically.