| 1 | package WordLists::Dict; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use WordLists::Sense; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use base qw(WordLists::WordList); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use WordLists::Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | our $VERSION = $WordLists::Base::VERSION; | |||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Scalar::Util; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | our $AUTOLOAD; | |||||||||
| 12 | |||||||||||
| 13 | sub new | ||||||||||
| 14 | { | ||||||||||
| 15 | 0 | ▶ | my ($class, $args) = @_; | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 16 | 0 | ▶ | $args->{'name'} = 'DICT' unless defined $args->{'name'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 0 | return WordLists::WordList::new($class,$args); | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | sub add_sense | ||||||||||
| 21 | { | ||||||||||
| 22 | 0 | ▶ | my ($self, $sense) = @_; | ||||||||
|
Subroutine
add_sense: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 23 | 0 | ▶ | warn "Sense already belongs to another dictionary" if $sense->{'#dictparent'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 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 | ||||||||||