line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WordLists::Dict;
|
2
|
1
|
|
|
1
|
|
11396
|
use strict;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
182
|
|
3
|
1
|
|
|
1
|
|
9
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
7
|
use utf8;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
12
|
|
5
|
1
|
|
|
1
|
|
1050
|
use WordLists::Sense;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw(WordLists::WordList);
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
603
|
|
7
|
1
|
|
|
1
|
|
6
|
use WordLists::Base;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
8
|
|
|
|
|
|
|
our $VERSION = $WordLists::Base::VERSION;
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use Scalar::Util;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
209
|
|
11
|
|
|
|
|
|
|
our $AUTOLOAD;
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new
|
14
|
|
|
|
|
|
|
{
|
15
|
0
|
|
|
0
|
1
|
|
my ($class, $args) = @_;
|
16
|
0
|
0
|
|
|
|
|
$args->{'name'} = 'DICT' unless defined $args->{'name'};
|
17
|
0
|
|
|
|
|
|
return WordLists::WordList::new($class,$args);
|
18
|
|
|
|
|
|
|
}
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub add_sense
|
21
|
|
|
|
|
|
|
{
|
22
|
0
|
|
|
0
|
0
|
|
my ($self, $sense) = @_;
|
23
|
0
|
0
|
|
|
|
|
warn "Sense already belongs to another dictionary" if $sense->{'#dictparent'};
|
24
|
0
|
|
|
|
|
|
$sense->set('dict', $self->{'name'});
|
25
|
0
|
|
|
|
|
|
$sense->{'#dictparent'} = $self;
|
26
|
0
|
|
|
|
|
|
Scalar::Util::weaken($sense->{'#dictparent'});
|
27
|
0
|
|
|
|
|
|
my $success = $self->_add_sense_to_list($sense);
|
28
|
0
|
|
|
|
|
|
$self->_index_sense($sense);
|
29
|
0
|
|
|
|
|
|
return $success;
|
30
|
|
|
|
|
|
|
}
|
31
|
|
|
|
|
|
|
1;
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=pod
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 NAME
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
WordLists::Dict
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $dict = WordLists::Dict->new({name=>'MyDictionary'});
|
42
|
|
|
|
|
|
|
$dict->add_sense($sense);
|
43
|
|
|
|
|
|
|
# $sense->get('dict') now returns 'MyDictionary'
|
44
|
|
|
|
|
|
|
my @senses = $dict->get_senses_for('head', 'verb');
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
A dictionary is a list of senses, rather like a wordlist, with the exception that adding a sense to a dictionary marks it as belonging to that dictionary.
|
49
|
|
|
|
|
|
|
This is useful when creating wordlists derived from several dictionaries, as you can then clearly see which belongs to which - if you remember to output dict, of course!
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 BUGS
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Please use the Github issues tracker.
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 LICENSE
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Copyright 2011-2012 © Cambridge University Press. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut
|