DiaColloDB/Document.pm

filter: Statementstmt 34.7% 8 / 23 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 25.0% 2 / 8 Podpod 50.0% 3 / 6 totaltotal 27.6% 13 / 47 CC 5 SCAR 17.3
CC
5
Cov
27%
STORABLE_freeze
12.0
new
6.0
label
6.0
CRAP 5.7
« DiaColloDB/Temp/Array.pm ↑ Summary DiaColloDB/Timer.pm »
1 ## -*- Mode: CPerl -*-
2 ## File: DiaColloDB::Document.pm
3 ## Author: Bryan Jurish <moocow@cpan.org>
4 ## Description: collocation db, source document
5  
6 package DiaColloDB::Document;
7 1 ▶use DiaColloDB::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 ##==============================================================================
11 ## Globals & Constants
12  
13 1 our @ISA = qw(DiaColloDB::Logger);
14  
15 ##==============================================================================
16 ## Constructors etc.
17  
18 ## $doc = CLASS_OR_OBJECT->new(%args)
19 ## + %args, object structure:
20 ## (
21 ## label => $label, ##-- document label (e.g. filename; optional)
22 ## date =>$date, ##-- year
23 ## tokens =>\@tokens, ##-- tokens, including undef for eos
24 ## meta =>\%meta, ##-- document metadata (e.g. author, title, collection, ...)
25 ## )
26 ## + each token in @tokens is one of the following:
27 ## - undef : EOS (default, for collocation profiling)
28 ## - a HASH-ref : normal token: {w=>$word,p=>$pos,l=>$lemma,...}
29 ## - a string : block boundary / "break", e.g. "s": sentence-break, "p": paragraph-break, ...
30 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
31 0 my $that = shift;
32 0 ▶ my $doc = bless({
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
33 label =>undef,
34 date =>0,
35 tokens=>[],
36 meta =>{},
37 @_, ##-- user arguments
38 },
39 ref($that)||$that);
40 0 return $doc;
41 }
42  
43 ##==============================================================================
44 ## API: I/O
45  
46 ## $bool = $doc->fromFile($filename_or_fh)
47 ## + parse tokens from $filename_or_fh
48 0 ▶sub fromFile {
Subroutine fromFile: not called CC=1 SCAR=6.9
Pod documented
49 0 my ($doc,$file) = @_;
50 0 $doc->logconfess("fromFile() not implemented for '$file': $!");
51 }
52  
53 ## $label = $doc->label()
54 0 ▶sub label {
Subroutine label: not called CC=2 SCAR=17.9
Pod documented
55 0 ▶ return $_[0]{label} // "$_[0]";
Condition0%0/2
$_[0]{"label"} // "$_[0]"
l!l
00
MC/DC0%0/1
$_[0]{"label"} // "$_[0]"
$_[0]{"label"}
Truth table0%0/2
A
A= $_[0]{"label"}
Aresult
11
00
56 }
57  
58 ## $ext = $doc->extension()
59 ## + default extension (including dot), for Corpus::Compiled
60 0 ▶sub extension {
Subroutine extension: not called CC=1 SCAR=6.9
Pod undocumented
61 0 return '';
62 }
63  
64 ##==============================================================================
65 ## Storable hooks
66  
67 ## ($serialized, $ref1, ...) = $obj->STORABLE_freeze($cloning)
68 0 ▶sub STORABLE_freeze {
Subroutine STORABLE_freeze: not called CC=3 SCAR=24.8
Pod undocumented
69 0 my ($obj,$cloning) = @_;
70 0 my $ref = {};
71 0 foreach (keys %$obj) {
72 0 ▶ $ref->{$_} = (UNIVERSAL::isa($obj->{$_},'Regexp') ? "$obj->{$_}" : $obj->{$_});
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($obj->{$_}, 'Regexp') ? : 0 0 0
73 }
74 0 return ('',$ref);
75 }
76  
77 ## $obj = STORABLE_thaw($obj, $cloning, $serialized, $ref1,...)
78 0 ▶sub STORABLE_thaw {
Subroutine STORABLE_thaw: not called CC=1 SCAR=6.9
Pod undocumented
79 0 my ($obj,$cloning,$ser,$ref) = @_;
80 0 @$obj{keys %$ref} = values %$ref;
81 0 return $obj;
82 }
83  
84  
85 ##==============================================================================
86 ## Footer
87 1 1;
88  
89 __END__
« DiaColloDB/Temp/Array.pm ↑ Summary DiaColloDB/Timer.pm »