NAME
Lingua::Phonology - an object model for lingistic phonology and sound change
SYNOPSIS
use Lingua::Phonology;
$phono = new Lingua::Phonology;
# Get sub-objects
$features = $phono->features;
$symbols = $phono->symbols;
$rules = $phono->rules;
$syllabification = $phono->syllable;
$segment = $phono->segment;
# Load phonology defaults
$phono->loadfile;
# Load a phonology definition from a file
$phono->loadfile('language.xml');
# Save phonology definition to a file
$phono->savefile('language.xml');
ABSTRACT
Lingua::Phonology is a unified module for handling phonological descriptions and units. It includes sub-modules for hierarchical (feature-geometric) sets of features, phonetic or orthographic symbols, individual segments, linguistic rules, syllabification algorithms, etc. It is written as an object-oriented module, wherein one will generally have a single object for the list of features, one for the phonetic symbols, one for the set of rules, etc., and multiple segment objects to be programatically manipulated.
DESCRIPTION
Lingua::Phonology is a module for modeling phonological descriptions of languages. It is designed with a classical generative phonology in mind, handing feature geometry, phonetic symbols, ordered rule sets, and syllabification algorithms. Both synchronic underlying-to-surface language change and diachronic language change can be modeled with this module. The module is designed to be very powerful and entirely programmatic, allowing you to define and manipulate a phonology entirely in perl, and it includes many features that you will probably never use. Some of the functionality of Lingua::FeatureMatrix and Lingua::SoundChange is duplicated here, but with much, much greater power.
Lingua::Phonology is split into several sub-modules, each of which does one specific thing. Here are the sub-modules, with a brief description of each:
-
Lingua::Phonology::Features allows you to define and manipulate the feature set that your language uses. This module allows for arbitrarily complex heirarchical feature geometry systems and implements one such system as its default, but you can also implement flat "classical" feature systems.
-
Lingua::Phonology::Segment, as its name implies, is the class that handles individual segments. Segments are associated with a feature set (a Lingua::Phonology::Features object), and are manipulated by various other modules.
-
Lingua::Phonology::Symbols is a class that acts as a "phonetic interpreter" for Lingua::Phonology::Segment objects. It takes a Segment and attempts to match it with a textual phonetic symbol. This module contains methods for defining and manipulating the set of phonetic symbols used.
-
Lingua::Phonology::Rules allows you to define processes that act upon words . You use this class to define the conditions and effects of each rule, and then apply that rule or many rules at once to a word.
-
Lingua::Phonology::Syllable is a subclass of Lingua::Phonology::Rules designed to handle syllabificaion. By setting just a few parameters, you can use this module to break a word up into syllables.
-
This module, unlike all of the others, is not object oriented. It provides a set of functions that can be used to make it easier to write rules for Lingua::Phonology::Rules.
When you create a Lingua::Phonology object with new Lingua::Phonology
, it comes bundled with a single object for each of these classes: Lingua::Phonology::Features, Lingua::Phonology::Symbols, Lingua::Phonology::Rules, Lingua::Phonology::Syllable. There are simple methods for accessing each of these objects. There is also a method that can be used to generate new Lingua::Phonology::Segment objects (since you will doubtlessly want more than one segment). The only module not automatically bundled with Lingua::Phonology is Lingua::Phonology::Functions, which you need to use
yourself if you want to access its functions.
The complete description of the function and use of each of these modules is on their respective man pages. It is recommended that you read these pages in the order given above to best understand them.
WARNINGS
Always use
them. Lingua::Phonology contains many useful warnings, but it generally will not display them unless use warnings
is on. All of the modules within Lingua::Phonology provide named warnings spaces, so you can turn the warnings specific to Lingua::Phonology or any submodule on or off.
use warnings 'Lingua::Phonology'; # use all warnings w/in Lingua::Phonology
no warnings 'Lingua::Phonology::Rules'; # ignore warnings coming from Lingua::Phonology::Rules
# etc.
METHODS
new
my $phono = new Lingua::Phonology;
Takes no arguments, and returns a new Lingua::Phonology object. This new object will contain one Lingua::Phonology::Features object, one Lingua::Phonology::Symbols object, one Lingua::Phonology::Rules object, and one Lingua::Phonology::Syllable object. These objects will be initialized to refer to one another where appropriate, so it is rarely necessary to use new
on any of the sub-modules.
features
my $features = $phono->features;
Returns the Lingua::Phonology::Features object associated with the current phonology. You may also pass a Features object as an argument, which sets the current Features object.
symbols
my $symbols = $phono->symbols;
Returns the current Lingua::Phonology::Symbols object. As with features()
, you can pass a Symbols object as an argument to set the current Symbols object, if desired.
rules
my $rules = $phono->rules;
Returns the current Lingua::Phonology::Rules object, or sets the current object if a Rules object is provided as an argument.
syllable
my $syllabification = $phono->syllable;
Returns a Lingua::Phonology::Syllable object, or sets the current object if a Syllable object is provided as an argument.
segment
my $seg = $phono->segment;
Returns a new Lingua::Phonology::Segment object associated with the current feature set and symbol set. This method takes no arguments, and cannot be used to initialize a segment. Therefore, it's probably easier to use the segment() method of Lingua::Phonology::Symbols (which you can access with $phono->symbols->segment($foo)
.
loadfile
# Load defaults
$phono->loadfile;
# Load phonology definition from a file
$phono->loadfile('phono.xml');
This method can be used to either load the defaults for all modules that come with defaults (currently Lingua::Phonology::Features and Lingua::Phonology::Symbols), or to load a phonology definition from a file.
Lingua::Phonology reads phonology definitions written in XML. The specification for the XML format that Lingua::Phonology reads is described in Lingua::Phonology::FileFormatPOD.
This method returns true on success, and undef on failure.
savefile
# Save to a file
$phono->savefile('phono.xml');
This method writes the current phonology state to the file given as the argument. The argument to this function may be the name of a file or a filehandle reference. If the name of a file is given, the file is truncated before the new file is written. The only way to append to an existing file is to pass a reference to a file opened in append mode.
This method returns undef if there is an error, else the string that was written to the file.
The file written is an XML document described in Lingua::Phonology::FileFormatPOD.
APOLOGIA
This module was written to fill my need for a truly versatile, sufficiently powerful way of handling phonologies. The existing Perl tools (Lingua::SoundChange and Lingua::FeatureMatrix) worked well enough for what they did, but they all lacked some functionality that I considered important. Thus, I decided to make my own tool. I have to a certain extent reinvented the wheel, but I prefer to think of it as replacing the wheel with a jet engine, since Lingua::Phonology is much more powerful than the existing modules.
Nonetheless, I am interested in integrating with existing tools, especially ones that are widely used and would be useful to others. Feel free to send me suggestions, or to make your own module interfacing Lingua::Phonology with whatever else.
BUGS
Probably. Please send bug reports and code improvements to the author.
SEE ALSO
Lingua::Phonology::FileFormatPOD
AUTHOR
Jesse S. Bangs <jaspax@cpan.org>.
This module is no longer actively maintained, though it does get occasional bugfixes. It has been superceded by a command-line tool called phonix
, which can be found at http://phonix.googlecode.com.
LICENSE
This module is free software. You can distribute and/or modify it under the same terms as Perl itself.