- COPYWRITE Copywrite (c) 2002, Chris Meyer. All rights reserved. This is free software and can be used under the same terms as Perl itself.
- RELATED LIBRARIES
Harvey::Word - Perl extension for creating word objects
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.
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 dictionary form, part of speech, many attributes on the basis of the part of speech, frequency, what persons are possible, i.e. 1st singular, 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 which case a boolean is returned. load_tie: Load a word record from the TIE hash (%t_word) into the memory hash (%word). Done automatically from the constructor. prioritize: Returns an ordered array of the most likely 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 freqeuncy counts. noun: Retuns the noun flags if the word is a noun, otherwise 0. Can be used as a boolean test for whether the word can be a noun, but also can set or retieve the noun flags for a word, which are stored as bytes in an integer. To set the flags, 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 prepositions. determiner: Same as noun, but for determiners. conjunction: Same as noun, but for conjunctions. 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 frequency. delete_word: Destroy the current word object determiner_freq: Gets/set the determiner frequency. conjunction_freq: Gets/set the conjunction frequency. 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 determiners. standalone_determiner: Get/set standalone flag for determiners. question_determiner: Get/set question flag for determiners. first_pronoun: Get/set first person flag for pronouns. second_pronoun: Get/set second person flag for pronouns. third_pronoun: Get/set third person flag for pronouns. singular_pronoun: Get/set singular flag for pronouns. plural_pronoun: Get/set plural flag for pronouns. masculine_pronoun: Get/set masculine flag for pronouns. feminine_pronoun: Get/set feminine flag for pronouns. neuter_pronoun: Get/set neuter flag for pronouns. nominative_pronoun: Get/set nominative flag for pronouns. accusativey_pronoun: Get/set accusative flag for pronouns. genitive_pronoun: Get/set genitive flag for pronouns. 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 pronouns. question_pronoun: Get/set question flag for pronouns. adjectival_pronoun: Get/set adjectival flag for pronouns: our your standalone_pronoun: Get/set standalone flag for pronouns: 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 most likely infinitive. adjective_dictionary: Get/set dictionary form for a adjective i.e. base adverb_dictionary: Get/set dictionary form for a adverb, i.e. base form noun_persons: Returns the possible persons for a noun. The 'persons' functions return an Integer with the possible persons (i.e. first singular, second plural, etc) stored as bits. This makes it easy to check for 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 modal works 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'.
None by default.
Chris Meyer, <firstname.lastname@example.org> 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.
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.