API Documentation

This section contains indications on how to access the SVN [1] and a doctest generated code documentation.

SVN (Subversion)

SVN is a tool used by many software developers to manage changes within their source code tree. SVN provides the means to store not only the current version of a piece of source code, but a record of all changes (and who made those changes) that have occurred to that source code. Use of SVN is particularly common on projects with multiple developers, since SVN ensures changes made by one developer are not accidentally removed when another developer posts their changes to the source tree.

In order to access a Subversion repository, you must install a special piece of software called a Subversion client. Subversion clients are available for most any operating system. You can check out the code through SVN with the following instruction set:

::
$ svn co https://sylli.svn.sourceforge.net/svnroot/sylli/trunk sylli

sylli.py

Syllable and syllabification Tool

class sylli.sylli.PhSegment(properties)

This class defines a phonological segment.

>>> segment = PhSegment(['p', '1', 'O'])

It is made of the segmental phonological representation

>>> print segment.segment
p

The sonority of the segment

>>> print segment.son
1

The natural class (O=Occlusives, F=Fricatives, V=Vowel etc.)

>>> print segment.pclass
O

The CV node, which defines whether the segment is (C)onsonat or vowel (V)

>>> print segment.cvcv
C
class sylli.sylli.SylModule(sonority='C:\Users\nijan\AppData\Roaming\Sylli\sonority.txt')

Core syllabification module.

fetch_lexicon(option, section='Segments')

Return a phonological segment or an option from the sonority file. The sonority file to be used is specified in self.lexicon.

>>> syl = SylModule()
>>> syl.fetch_lexicon('a')
'a, 22, V'
>>> syl.fetch_lexicon('output', section='General')
'str'
input_transducer(input_string, transducer=0)

The transducer can perform only two operations: Ship and Translate. Translate converts a string into the corresponding phonological object Ship, ships a translated sequence to the Syllabification Algorithm.

>>> syl = SylModule()
>>> for seg in syl.input_transducer('io'):
...     print seg.segment, seg.son, seg.pclass
i 22 V
o 22 V
load_conf(sonority_file)

Load $HOME configuration file sonority.txt. It first looks if $HOME/.sylli is already there, if not it creates it. It then set the attribute self.sonority_file (sonority filename) and self.lexicon (ConfigParser object).

>>> syl = SylModule()
>>> syl.load_conf('config/sonority.txt')
True

The class method also sets most class attributes

>>> print syl.output, syl.extra
str 1
output_transducer(sequence)

Segments, sonorities, natural classes and syllable boundaries are flattened into one dimension ready to be printed in a sequential, phisical form.

>>> syl = SylModule()
>>> psequence = syl.input_transducer('kasa')
>>> syllabified = syl.sa(psequence)
>>> syl.output_transducer(syllabified)
'ka.sa'
sa(sequence)

Divide a phonematic sequence into syllables. The sequence is list of phonological objects. Each object is evaluated using an extremely simple syllabification algorithm based on the Sonority Sequencing Principle. It puts a syllable boundary after every minimum, or when two consequtive sonorities are equal

>>> syl = SylModule()
>>> ph_sequence = syl.input_transducer('io')
>>> for seg in syl.sa(ph_sequence):
...     print seg.segment, seg.son, seg.pclass
i 22 V
o 22 V
syllabify(sequence)

It goes through the three sub-modules/methods of the class. First it transduce the sequence, then it ships it to the SA and finally to the output transducer. The main method of the class.

>>> syl = SylModule()
>>> syl.syllabify('kasa')
'ka.sa'
sylli.sylli.detimit(timitf)

strip out TIMIT off a file.

>>> detimit('test/files/sample.std')
['__', 'ma%', '%"io', 'nO', 'tSe', 'l-"O', 'la', 'farf"alla']
sylli.sylli.dirl(input_dir, ext=0)

Return a dictionary of the form filename:content of a directory

>>> dirl('test/files/') 
{'test/files/sample.std': ['__ ma% %"io nO tSe l-"O la farf"alla'],...

You can specify a file extention, in this case, only files with such extension will be parsed.

>>> print dirl('test/files/', ext='std')
{'test/files/sample.std': ['__ ma% %"io nO tSe l-"O la farf"alla']}
sylli.sylli.filel(input_f)

Return a a list of string with the content of a file, if it is a TIMIT, it stript the TIMIT off.

>>> filel('test/files/sample.std')
['__ ma% %"io nO tSe l-"O la farf"alla']
sylli.sylli.main(argv)

Run the command line script.

Note that Sylli always requires an argument.

>>> main(argv='') 
sylli: use at least one argument...

The simplest way to use Sylli is to syllabify a string

>>> main(['-s', 'la kapra'])
la.ka.pra

You can also syllabify a timit file, which will be parsed as single string.

>>> main(['-f', 'test/files/sample.phn'])
no.na.i.u.na.farf.fal.la.al.lo.ra.swo.pra.la.mi.a.mak.kji.ni.nab.blu

Or a text file. The lines are feeded into sylli one by one.

>>> main(['-f', 'test/files/sample.txt'])
O.vis.to.u.na.vol.pe.ne.ra
trop.pes.tel.le.bril.la.no.in.tSE.lo

or a directory:

>>> main(['-d', 'test/files'])
ma.i.o.nO.tSe.lO.la.far.fal.la
O.vis.to.u.na.vol.pe.ne.ra.trop.pes.tel.le.bril.la.no.in.tSE.lo
no.na.i.u.na.farf.fal.la.al.lo.ra.swo.pra.la.mi.a.mak.kji.ni.nab.blu

You can also run a demo of the program

>>> main(['-z']) 
<BLANKLINE>
Frequent clusters:
pane -> pa.ne
OLLo -> OL.Lo
...

Other options allow you to print the current version

>>> main(['-v']) 
sylli-0.9.8
Copyright 2010 Luca Iacoponi...

Or the help screen

>>> main(['-h']) 
Usage: sylli [OPTION]... [FILE|string]...

Sylli will automatically look for the sonority.txt in your $HOME. But you can always use another configuration file. Remember to use -c option before any other.

>>> main(['-c', 'test/crazysonority.txt', '-s', 'papa'])
p.a.p.a

Finally, you can run sylli in interactive mode.

>>> main(['-i']) 
sylli.sylli.reset_son()

Restore installation sonority overwriting current sonority

sylli.sylli.usage()

Return usage help.

>>> print usage() 
Usage: sylli [OPTION]... [FILE|string]...
Divides a file, a string or a directory into syllable....
sylli.sylli.version()

Return the version of the program and other information

>>> print version() 
sylli-0.9.8
Copyright 2010 Luca Iacoponi...

filepath.py

a cross-platform way to get user’s home directory

sylli.filepath.get_config_dir()

Get config dir on Windows

>>> get_config_dir()
C:\Users\nijan\AppData\Roaming
sylli.filepath.get_dir_root(shellvars)

Get root directory of a env var

>>> get_dir_root('${HOME}')
'/home/alice'
sylli.filepath.get_home_dir()

Get home directory

>>> get_home_dir()
'/home/alice'
sylli.filepath.get_path(path)

Get a path of a specific sylli’s location

>>> get_path('config_dir')
'/home/alice/.sylli'
>>> get_path('inst_sonority')
'/home/alice/Sylli/sylli/config/sonority.txt'
>>> get_path('usr_sonority')
'/home/alice/.sylli/sonority.txt'
>>> get_path('images')
'/home/alice/Sylli/sylli/images'

ui.py

UI for Sylli

class sylli.ui.ContentFrame(parent)

Frame for the Content window

class sylli.ui.MyApp(redirect=True, filename=None, useBestVisual=False, clearSigInt=True)

Create the wxApp object which contains the main frame and show it.

OnInit()

Initialise the application

class sylli.ui.MyFileDropTarget(window)

Create a drop target. It adds to a form the filenames of the files dropped in.

class sylli.ui.MyFrame(parent, title)

Main frame. Includes the icon, menu bar, help bar, status bar and the two panels: one with the widgets, the other with the control for the sdout/stderr text.

OnAbout(evt)

A wx about box.

OnContents(evt)

A wx frame showing the program documentation

OnEditS(evt)

Edit the current working sonority file

OnLoadS(evt)

Load an alternative sonority file

OnMenu(evt)

Update the status bar sonority

OnNewS(evt)

Create a new sonority file, using installation sonority as a template.

OnQuit(evt)

Quit, destroy the main frame

OnResetS(evt)

Restore installation sonority.txt by copying it into user’s home

conf_update(new_son)

Set a new sonority file as the one in use in UI and SylModule.

create_helpbar()

Creates the help bar.

create_menu(menudata)

Create a menu of the menu bar.

create_menubar()

Get the data from menudata() and create the menu bar.

err_dial(msg)

Show an error dialog.

menudata()

Return data to be included in the menu bar.

ui_update()

Update all widgets to reflect the SylModule attribute values.

class sylli.ui.MyHtmlWindow(parent)

Create an html Window for displaying the documentation

class sylli.ui.MyPanel(parent, panel_id)

Main panel of the program, it contains all the widgets.

OnDemo(evt)

Run the demo module demo, showing syllabification examples.

OnQuit(evt)

Quit, destroy the frame

OnReload(evt)

Set working sonority (which may have been edited or changed) as SylModule sonority,

build_button(parent, label, handler, tooltip)

Create a button.

button_data()

Contains the data of the three buttons on the bottom

create_buttonbar(panel)

Create the three buttons on the bottom of the panel

class sylli.ui.NoteTab(parent, tab_type)

Create a note tab panel

OnDirButton(evt)

Show a dialog to choose the directory to syllabify

OnFileButton(evt)

Show a dialog to choose the file to syllabify

class sylli.ui.RedirectText(aWxTextCtrl)

Redirect the stdout/stderr output to a wx text control.

sylli.ui.filedial(obj, wildcard, defdir)

Create an open file dialog.

sylli.ui.get_bitmap(bitmap)

Return one of the png in images/ as a bitmap object

sylli.ui.get_ico(ico)

Return one of the icon in images/ as an ico object

sylli.ui.main(debug=0)

Run the application. Create a wx.App object and run MainLoop method.

sylli.ui.savedial(obj, wildcard, defdir, msg)

Create a save file dialog.

sylli.ui.syllabify_list(file_list, write=0)

Syllabify files in the list

sylli.ui.writefile(filename, content)

Write in file $filename a content $content

demo.py

Syllabification demo

sylli.demo.demo(syl, phn=0)

A demo showing most relevant syllabifications in Italian

>>> syl = sylli.SylModule()
>>> demo(syl) 
<BLANKLINE>
Frequent clusters:
pane -> pa.ne
OLLo -> OL.Lo
...
sylli.demo.main()

Run the demo

postinst.py

Execute post-install operations

sylli.postinst.main()

Run post-install user alert.

sylli.postinst.user_alert()

Alert the user that a configuration directory already exists and eventually overwrite the user sonority with the installation one. >>> user_alert()

Table Of Contents

Previous topic

Examples of Syllabifications

This Page