lib/Treex/Core.pm

filter: Statementstmt 100% 21 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 27 / 27 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/Treex/Block/Write/Text.pm ↑ Summary lib/Treex/Core/DocZone.pm »
1 package Treex::Core;
2 {
3 37 $Treex::Core::VERSION = '0.08633_1';
4 }
5 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 37 ▶use Treex::Core::Document;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 37 ▶use Treex::Core::Node;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 37 ▶use Treex::Core::Bundle;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 37 ▶use Treex::Core::Scenario;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 37 1;
13  
14 __END__
15  
16 =pod
17  
18 =encoding utf8
19  
20 =head1 NAME
21  
22 Treex::Core - interface to linguistic structures and processing units in Treex
23  
24 =head1 VERSION
25  
26 version 0.08633_1
27  
28 =head1 SYNOPSIS
29  
30 use Treex::Core;
31
32 my $doc = Treex::Core::Document->new;
33
34 my $bundle = $doc->create_bundle;
35 my $zone = $bundle->create_zone('en');
36 my $atree = $zone->create_atree;
37
38 my $predicate = $atree->create_child({form=>'loves'});
39
40 foreach my $argument (qw(John Mary)) {
41 my $child = $atree->create_child( { form=>$argument } );
42 $child->set_parent($predicate);
43 }
44
45 $doc->save('demo.treex');
46  
47  
48 =head1 DESCRIPTION
49  
50 C<Treex::Core> is a library of modules for processing linguistic data,
51 especially tree-shaped syntactic representations of natural language
52 sentences, both for language analysis and synthesis purposes.
53  
54 C<Treex::Core> is meant to be as language universal as possible.
55 It makes only a few assumptions: the language's written form must be
56 representable by Unicode characters, and it should be possible to segment
57 texts in such language into sentences (or sentence-like units) and words
58 (or word-like units).
59  
60 C<Treex::Core> is tightly coupled with the tree editor TrEd, which
61 makes browsing the linguistic data structures very comfortable.
62  
63 C<Treex::Core> uses TrEd's L<Treex::PML> for the memory
64 representation, as well as for storing the data into *.treex files, using
65 the XML-based Prague Markup Language.
66  
67  
68 =head2 Zones parametrized by language codes and selectors
69  
70 Treex documents can contain parallel texts in two or more languages,
71 as well as alternative linguistic representations (such as two
72 dependency parses of a same sentence, resulting from different parsers).
73 Such contents of the same type are separated by introducing zones.
74  
75 Zones (classes derived from L<Treex::Core::Zone>) are
76 parametrized by language ISO codes, and optionally also by so called
77 selectors. Selector can be any string identifying the source or purpose of the
78 given piece of data. It can distinguish e.g. reference translation from
79 machine-translated text, or the most probable parse of a given sentence from
80 the second most probable parse. In Treex data structures, zones are used at
81 two levels:
82  
83 - L<Treex::Core::DocZone> - allows to have multiple texts
84 stored in the same document
85  
86 - L<Treex::Core::BundleZone> - allows to have multiple
87 sentences and their representations in each bundle.
88  
89 As for Treex processing units (scenarios and blocks, see below), each
90 processing unit either limits itself to a certain zone, or it can be
91 zone-parametrized (especially in the case of language-universal blocks).
92  
93 =head2 Data structure units
94  
95 In Treex, linguistic representations of running texts are organized
96 in the following hierarchy:
97  
98 =head3 Documents
99  
100 The smallest independently storable unit is a document
101 (L<Treex::Core::Document>).
102  
103 Technically, each document consists of a set of document zones, and of a
104 sequence of bundles.
105  
106 =head3 Document zone
107  
108 A document can contain one ore more zone
109 (L<Treex::Core::DocZone>), each of them containing a text.
110 =head3 Bundle
111  
112 A bundle (L<Treex::Core::Bundle>) corresponds to a
113 sentence (or a tuple of parallel or alternative sentences) and all its (or
114 their) linguistic analyses.
115  
116 Technically, a bundle contains a set of bundle zones.
117  
118 =head3 Bundle zone
119  
120 Bundle zone (L<Treex::Core::Bundle>) contains one sentence
121 and at most one its linguistic analysis for each layer of analysis. The
122 following layers are currently distinguished:
123  
124 * a-layer - analytical layer (surface syntax dependency layer) merged with the
125 morphological layer, as defined in the Prague Dependency Treebank.
126  
127 * t-layer - tectogrammatical layer (deep-syntactic dependency)
128  
129 * p-layer - phrase-structure layer
130  
131 * n-layer - named entity layer
132  
133 Each layer representation has a form of a tree, represented by the tree's root node.
134  
135 =head3 Node
136  
137 Each node has a parent (unless it is the root) and a set of predefined
138 attributes, depending on the layer it belongs to. There is an abstract class
139 L<Treex::Core::Node> defining the functionality which is
140 common to all types of trees (such as functions for accessing node's parent or
141 children). Functionality specific for the individual linguistic layers is
142 implemented in the derived classes:
143  
144 * L<Treex::Core::Node::A>
145  
146 * L<Treex::Core::Node::T>
147  
148 * L<Treex::Core::Node::P>
149  
150 * L<Treex::Core::Node::N>
151  
152 =head3 Attributes
153  
154 Nodes contain attribute-value pairs. Some attributes are universal (such as
155 identifier), but most of them are specific for a certain layer. Even if node
156 instances are regular Moose objects (i.e., blessed hashes), node's attributes
157 should be accessed exclusively via predefined accessors.
158  
159 Attribute values can be plain or further structured using PML data types (e.g.
160 sequences), according to the PML schema.
161  
162  
163 =head2 Processing units
164  
165 =head3 Block
166  
167 Blocks (descendants of L<Treex::Core::Block>) are the
168 smallest processing units applicable on Treex documents.
169  
170 =head3 Scenario
171  
172 Scenarios (instances of L<Treex::Core::Scenario>) are
173 sequences of blocks. Blocks from a scenario are applied on a document one
174 after another.
175  
176 =head2 Support for visualizing Treex trees in TrEd
177  
178 C<Treex::Core> also contains a TrEd extension for browsing .treex files.
179 The extension itself is only a thin wrapper for the viewing functionality
180 implemented in L<Treex::Core::TredView>.
181  
182  
183 =head1 AUTHOR
184  
185 Zdeněk Žabokrtský <zabokrtsky@ufal.mff.cuni.cz>
186  
187 Martin Popel <popel@ufal.mff.cuni.cz>
188  
189 David Mareček <marecek@ufal.mff.cuni.cz>
190  
191 =head1 COPYRIGHT AND LICENSE
192  
193 Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague
194  
195 This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
« lib/Treex/Block/Write/Text.pm ↑ Summary lib/Treex/Core/DocZone.pm »