NAME
Treex::Core::Document - representation of a text and its linguistic analyses in the Treex framework
VERSION
version 0.05222
DESCRIPTION
A document consists of a sequence of bundles, mirroring a sequence of natural language sentences (typically, but not necessarily, originating from the same text). Attributes (attribute-value pairs) can be attached to a document as a whole.
ATTRIBUTES
Treex::Core::Document's instances have the following attributes:
- description
-
Textual description of the file's content that is stored in the file.
- loaded_from
- path
- file_stem
- file_number
The attributes can be accessed using semi-affordance accessors: getters have the same names as attributes, while setters start with 'set_'. For example by getter path()
and setter set_path($path)
METHODS
Constructor
- my $new_document = Treex::Core::Document->new;
-
creates a new empty document object.
- my $new_document = Treex::Core::Document->new( { pmldoc => $pmldoc } );
-
creates a Treex::Core::Document instance from an already existing Treex::PML::Document instance
- my $new_document = Treex::Core::Document->new( { filename => $filename } );
-
loads a Treex::Core::Document instance from a .treex file
Access to zones
Document zones are instances of Treex::Core::DocZone, parametrized by language code and possibly also by another free label called selector, whose purpose is to distinguish zones for the same language but from a different source.
- my $zone = $doc->create_zone( $langcode, ?$selector );
- my $zone = $doc->get_zone( $langcode, ?$selector );
- my $zone = $doc->get_or_create_zone( $langcode, ?$selector );
Access to bundles
- my @bundles = $document->get_bundles();
-
Returns the array of bundles contained in the document.
- my $new_bundle = $document->create_bundle();
-
Creates a new empty bundle and appends it at the end of the document.
- my $new_bundle = $document->new_bundle_before( $existing_bundle );
-
Creates a new empty bundle and inserts it in front of the existing bundle.
- my $new_bundle = $document->new_bundle_after( $existing_bundle );
-
Creates a new empty bundle and inserts it after the existing bundle.
Node indexing
- $document->index_node_by_id( $id, $node );
-
The node is added to the id2node hash table (as mentioned above, it is done automatically in $node->set_attr() if the attribute name is 'id'). When using undef in the place of the second argument, the entry for the given id is deleted from the hash.
- my $node = $document->get_node_by_id( $id );
-
Return the node which has the value $id in its 'id' attribute, no matter to which tree and to which bundle in the given document the node belongs to.
It is prohibited in Treex for IDs to point outside of the current document. In rare cases where your data has such links, we recommend you to split the documents differently or hack it by dropping the problematic links.
- $document->id_is_indexed( $id );
-
Return true if the given id is already present in the indexing table.
- $document->get_all_node_ids();
-
Return the array of all node identifiers indexed in the document.
Other
AUTHOR
Zdeněk Žabokrtský <zabokrtsky@ufal.mff.cuni.cz>
Martin Popel <popel@ufal.mff.cuni.cz>
COPYRIGHT AND LICENSE
Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.