word(3)
NAME
Harvey::Word - Perl extension for creating word objects
SYNOPSIS
use Harvey::Word;
my $W = Word->new("grape");
Word object module for Harvey. Looks up information
on
a word for all forms and gives information to calling
objects.
Version 1.02 Overhauled and improved word.txt/word.db
database.
Added better cross referencing to move between verb,
noun, adj and
adverb forms.
DESCRIPTION
- The purpose of the Word module is to create Word objects
- that can be
queried for syntactic information about the word.
Version 1.01, words can be queried for their dictio- nary form, part
of speech, many attributes on the basis of the part of - speech,
frequency, what persons are possible, i.e. 1st singu - lar, 3rd plural,
etc., and the likeliest parts of speech that the word - could be based
on the frequencies in the BNC. - Most methods which return a characteristic of the word
- can also be
used to turn on or off the characteristic by passing a - 0 or 1 for
boolean flags, text for text queries and numbers for - the frequency.
- The data is used from a TIE hash database, but can be
- exported/imported
from the ASCII file word.txt using the export_word and - import_word
functions. - The following methods are supported:
new: Constructor.
text: Get the text of the word. Version 1.02- added the ability
to pass in a standard expression for pattern matching
against the text of the object, in whichcase a boolean
is returned. - load_tie: Load a word record from the TIE hash
- (%t_word) into the
memory hash (%word). Done automaticallyfrom the constructor.
- prioritize: Returns an ordered array of the most like
- ly parts of speech
for a given word based on the BNC frequency counts.
- choice: Returns an array of strings of the most
- likely POS choices
for a word object based on BNC freqeuncycounts.
- noun: Retuns the noun flags if the word is a
- noun, otherwise 0. Can
be used as a boolean test for whether theword can be a noun,
but also can set or retieve the noun flagsfor a word, which are
stored as bytes in an integer. To set theflags, send in an
integer as the argument. - verb: Same as noun, but for verbs.
adjective: Same as noun, but for adjectives.
adverb: Same as noun, but for adverbs.
modal: Same as noun, but for modals.
pronoun: Same as noun, but for pronouns.
preposition: Same as noun, but for preposi - tions.
determiner: Same as noun, but for determiners.
conjunction: Same as noun, but for conjunc - tions.
noun_freq: Gets/set the noun frequency.
verb_freq: Gets/set the verb frequency.
adjective_freq: Gets/set the adjective frequency.
adverb_freq: Gets/set the adverb frequency.
modal_freq: Gets/set the modal frequency.
pronoun_freq: Gets/set the pronoun frequency.
preposition_freq: Gets/set the preposition frequen - cy.
delete_word: Destroy the current word object
determiner_freq: Gets/set the determiner frequency.
conjunction_freq: Gets/set the conjunction frequen - cy.
coord_conjunction: Gets/set coordinating flag for - conjunctions.
subord_conjunction: Gets/set subordinating - flag for conjunctions.
adverb_preposition: Gets/set whether preposition can - be used
alone as adverb.
- base_adjective: Gets/set base flag for adjectives.
comparative_adjective: Gets/set comparative flag - for adjectives.
superlative_adjective: Gets/set superlative flag - for adjectives.
base_adverb: Gets/set base adverb flag.
comparative_adverb: Gets/set comparative adverb flag.
superlative_adverb: Gets/set superlative adverb flag.
singular determiner: Gets/set singular flag for - determiners.
plural_determiner: Get/set plural flag for determin - ers.
standalone_determiner: Get/set standalone flag - for determiners.
question_determiner: Get/set question flag for - determiners.
first_pronoun: Get/set first person flag for pro - nouns.
second_pronoun: Get/set second person flag for - pronouns.
third_pronoun: Get/set third person flag for pro - nouns.
singular_pronoun: Get/set singular flag for pro - nouns.
plural_pronoun: Get/set plural flag for pronouns.
masculine_pronoun: Get/set masculine flag for pro - nouns.
feminine_pronoun: Get/set feminine flag for pro - nouns.
neuter_pronoun: Get/set neuter flag for pronouns.
nominative_pronoun: Get/set nominative flag for pro - nouns.
accusativey_pronoun: Get/set accusative flag - for pronouns.
genitive_pronoun: Get/set genitive flag for pro - nouns.
person_pronoun: Get/set person flag for pronouns.
place_pronoun: Get/set place flag for pronouns.
thing_pronoun: Get/set thing flag for pronouns.
reflexive_pronoun: Get/set reflexive flag for pro - nouns.
question_pronoun: Get/set question flag for pro - nouns.
adjectival_pronoun: Get/set adjectival flag for pro - nouns: our your
standalone_pronoun: Get/set standalone flag for pro - nouns: ours yours
singular_noun: Get/set singular flag for nouns.
plural_noun: Get/set plural flag for nouns.
numberless_noun: Get/set numberless flag for nouns.
proper_noun: Get/set proper flag for nouns.
masculine_noun: Get/set masculine flag for nouns.
feminine_noun: Get/set feminine flag for nouns.
neuter_noun: Get/set neuter flag for nouns.
starter_noun: Get/set starter flag for nouns.
infinitive_verb: Get/set infinitive flag for verbs.
past_verb: Get/set infinitive flag for verbs.
participle_verb: Get/set infinitive flag for verbs.
third_verb: Get/set infinitive flag for verbs.
gerund_verb: Get/set infinitive flag for verbs.
present_verb: Get/set infinitive flag for verbs.
starter_verb: Get/set infinitive flag for verbs.
noun_dictionary: Get/set dictionary form for a - noun, ie. singular.
verb_dictionary: Get/set dictionary form for a - verb, ie. infinitive,
1.02 added argument to verb_dictionary. Pass in
the verb part(Present|Past|Third|Infinitive|Gerrund
|Participle) to determine the mostlikely infinitive. - adjective_dictionary: Get/set dictionary form for a
- adjective i.e. base
adverb_dictionary: Get/set dictionary form for a ad - verb, i.e. base form
noun_persons: Returns the possible persons for a - noun. The 'persons'
functions return an Integer withthe possible persons
(i.e. first singular, second plural, etc) stored as
bits. This makes it easy to checkfor Subject verb
agreement or pronoun/noun agreement by 'anding' the
flags together. - pronoun_persons: Returns the possible persons for a
- pronoun.
verb_persons: Returns the possible persons for a - verb.
modal_persons: Added with 1.02 since modals have - slightly different
person patterns, e.g. can as a modalworks with 'he',
while can as a verb does not. - tie_hash: Ties the hash, %t_word to the file
- dic/word.db.
import_word: Builds the hash TIE file - 'dic/word.db' from
the text file 'word.txt'.
- export_word: Exports data from the TIE file
- 'dic/word.db'
to the text file 'word.txt'.
- EXPORT
- None by default.
AUTHOR
Chris Meyer, <chris@mytechs.com> www.mytechs.com
COPYWRITE Copywrite (c) 2002, Chris Meyer. All rights reserved.
- This is free software and can be used under the same terms as Perl itself. VERSION
- 1.02
RELATED LIBRARIES
- My heartfelt thanks to Adam Kilgarriff for his work on
- the BNC
(British National Corpus) which forms the basis for the - word.db.
I have added and massaged it a bit, but I would never - have gotten
this far without it. The BNC can be visited at
http://www.itri.brighton.ac.uc/~Adam.Kilgarriff/bnc - readme.html.
- the perl manpage.