Treex::Core::Document - representation of a text and its linguistic analyses in the Treex framework
version 2.20210102
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.
Note that the references from the bundles to the containing document are weak, so make sure you always keep a reference to the document in scope to prevent the contents of the document from being garbage-collected.
Treex::Core::Document's instances have the following attributes:
Treex::Core::Document
Textual description of the file's content that is stored in the file.
The attributes can be accessed using semi-affordance accessors: getters have the same names as attributes, while setters start with set_. For example, the attribute path has a getter path() and a setter set_path($path)
set_
path
path()
set_path($path)
creates a new empty document object.
creates a Treex::Core::Document instance from an already existing Treex::PML::Document instance
loads a Treex::Core::Document instance from a .treex file
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.
Returns the array of bundles contained in the document.
Creates a new empty bundle and appends it at the end of the document.
Creates a new empty bundle and inserts it in front of the existing bundle.
Creates a new empty bundle and inserts it after the existing bundle.
The node is added to the document's indexing table id2node (it is done automatically in Treex::Core::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.
id2node
id
undef
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.
$id
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.
Return true if the given id is already present in the indexing table.
true
Return the array of all node identifiers indexed in the document.
Return all references leading to the given node id in a hash (keys are reference types, e.g. 'alignment', 'a/lex.rf' etc., values are arrays of nodes referencing this node).
Remove all references to the given node id (calls remove_reference() on each referencing node).
Loads document from $filename given %opts using Treex::PML::Document::load()
$filename
%opts
Saves document to $filename using Treex::PML::Document::save(), or by the Storable module if the file's extension is .streex.gz.
Loading a document from the .streex (Storable) format.
full filename without the extension
Zdeněk Žabokrtský <zabokrtsky@ufal.mff.cuni.cz>
Martin Popel <popel@ufal.mff.cuni.cz>
Ondřej Dušek <odusek@ufal.mff.cuni.cz>
Copyright © 2011-2012 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.
To install Treex::Core, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Treex::Core
CPAN shell
perl -MCPAN -e shell install Treex::Core
For more information on module installation, please visit the detailed CPAN module installation guide.