Download the PHP package zachleigh/pronounce-php without Composer
On this page you can find all versions of the php package zachleigh/pronounce-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zachleigh/pronounce-php
More information about zachleigh/pronounce-php
Files in zachleigh/pronounce-php
Package pronounce-php
Short Description Create English pronunciation strings for over 130,000 words. Hyphenate English words.
License GPL-2.0
Homepage https://github.com/zachleigh/pronounce-php
Informations about the package pronounce-php
Pronounce-PHP
-Converts words to pronunciation strings using the Carnegie Mellon University Pronouncing Dictionary (CMUdict) file. Currently converts to the International Phonetic Alphabet (IPA) and to an easier to read spelling approximation.
-Hyphenates English words. Hyphenation for IPA and spelling approximation hopefully coming soon.
-Outputs to the console, to a file, or to a database
Contents
Installation
Usage
- Commands
- all
- hyphenate
- lookup
- Database Usage
Installation
Requirements
PHP 5.3.9 or higher
Linux users can find PHP releases in their distribution repositories. For other operating systems, please visit the php installation guide for instructions.
composer
Check the composer documentation for installation instructions.
Install
If requirements are met, you can install the package in two ways.
Download
Recommended. Download here and run
Through composer
If you install through composer, the program will be in vendor/zachleigh/pronounce-php
Usage
General syntax overview
Commands
- all
- hyphenate
- lookup
all
Output the entire CMUdict file with arpabet, hyphenation, IPA, and spelling approximation strings to either a file or a database. Default is to write to a file called 'output.txt'.
Syntax overview
Options
--destination [-d]
Set the output destination. Default is to output to a file called 'output.txt'. If file is selected (default), fields will be seperated by a forward slash (/) surrounded by spaces.
Available desitinations: [file, database]
--fields [-f]
Set the output fields to be displayed. Fields must be in a comma seperated list. All fields are enabled by default.
Available fields: [word, hyphenated_word, arpabet, ipa, spelling]
--file [-o]
If 'file' is selected for the output destination, the 'file' option can be used to set a file name to write to. The default file name is 'output.txt' and is written to the pronounce-php directory.
--multiple [-m]
For some words in the CMUdict file, there are multiple pronunciation entries. The file deals with these by appending a number in parentheses to each additional entry.
The 'multiple' command sets the behavior to deal with thses multiple entries for the output. By default, 'multiple' is set to 'none', which outputs entries exactly as they appear in the CMUdict file. 'repeat' outputs entries without the parentheses or numbers.
--symbol [-s]
Set the character to be used for hyphenation. The default value is a hyphen (-). Note: if writing to a file, keep in mind that items in the file will be divided by forward slashes(/) so setting the hyphenation symbol to forward slash will complicate reading of the file.
Examples
Basic usage
Set desired output fields with the 'fields' option.
Change the symbol used to divide the hyphenated word with the 'symbol' option.
Set the ouput destination with the 'destination' option. Only one destination may be choosen. If 'destination' is set to 'file' (the default value), use the 'file' option to specify a file to write to.
If 'destination' is set to 'database', database credentials will be read from .env and configuration will be read from config.php.
hyphenate
Hyphenate a word or words. Note that this function is mostly accurate, but there may be some errors. If you find an error, please report it so I can add the word to the exception list.
Syntax overview
Options
--destination [-d]
Set the output destination. Default is to output a table to the console. If file is selected, fields will be seperated by a forward slash (/) surrounded by spaces.
Available desitinations: [table, string, file, database]
--file [-o]
If 'file' is selected for the output destination, the 'file' option can be used to set a file name to write to. The default file name is 'output.txt' and is written to the pronounce-php directory.
--symbol [-s]
Set the character to be used for hyphenation. The default value is a hyphen (-). Note: if writing to a file, keep in mind that items in the file will be divided by forward slashes(/) so setting the hyphenation symbol to forward slash will complicate reading of the file.
Examples
Basic usage
A comma seperated list of words may also be given.
Change the symbol used to divide word with the 'symbol' option.
Set the ouput destination with the 'destination' option. Only one destination may be choosen. Setting 'destination' to 'string' produces a string instead of a table.
Setting 'destination' to 'file' writes the output to a file. The default file is 'output.txt'.
ouput.txt
If 'destination' is set to 'file', use the 'file' option to specify a file to write to.
hyphen.txt
If 'destination' is set to 'database', database credentials will be read from .env and configuration will be read from config.php.
lookup
Look up a word and output the Arpabet, IPA and Spelling approximation pronunciation strings. The lookup command takes one argument: the word or words to be looked up.
Syntax overview
Options
--destination [-d]
Set the output destination. Default is to output a table to the console. If 'file' is selected, fields will be seperated by a forward slash (/) surrounded by spaces.
Available desitinations: [table, string, file, database]
--fields [-f]
Set the output fields to be displayed. Fields must be in a comma seperated list. All fields are enabled by default.
Available fields: [word, arpabet, ipa, spelling]
--file [-o]
If 'file' is selected for the output destination, the 'file' option can be used to set a file name to write to. The default file name is 'output.txt' and is written to the pronounce-php directory.
--hyphenate [-y]
If the 'hyphenate' flag is given, applicable fields will be hyphenated. Currently, only the 'word' field may be hyphenated.
--multiple [-m]
For some words in the CMUdict file, there are multiple pronunciation entries. The file deals with these by appending a number in parentheses to each additional entry.
The 'multiple' command sets the behavior to deal with thses multiple entries for the output. By default, 'multiple' is set to 'none', which outputs entries exactly as they appear in the CMUdict file. 'repeat' outputs entries without the parentheses or numbers.
--symbol [-s]
Set the character to be used for hyphenation. The default value is a hyphen (-). Note: if writing to a file, keep in mind that items in the file will be divided by forward slashes(/) so setting the hyphenation symbol to forward slash will complicate reading of the file.
Examples
Basic usage
A comma seperated list of words may also be given. Note that words will be returned in alphabetical order.
Using the 'hyphenate' flag hyphenates the 'word' field.
Use the 'symbol' option to set the character used for hyphenation.
Set desired output fields with the 'fields' option. Fields will be displayed in the order given.
Set the ouput destination with the 'destination' option. Only one destination may be choosen.
Setting 'destination' to 'string' produces a string instead of a table.
Setting 'destination' to 'file' writes the output to a file. The default file is 'output.txt'.
ouput.txt
If 'destination' is set to 'file', use the 'file' option to specify a file to write to.
words.txt
If 'destination' is set to 'database', database credentials will be read from .env and configuration will be read from config.php.
Database Usage
Requirements
If you wish to fill a database with the information gained from using this program, you must be sure that your database meets the following requirements:
- Tables must have an auto-incrementing 'id' column
- Column names must exactly match the expected field names.
- All command field names: 'word', 'hyphenated_word', 'arpabet', 'ipa', 'spelling'
- Hyphenate command field names: 'word', 'hyphenated_word'
- Lookup command field names: 'word', 'arpabet', 'ipa', 'spelling'
Use the 'field' option to set which fields you wish to insert into your database.
Setup
First, copy the .env.example file (found in the pronounce-php root folder) to a new file called .env. Open the .env file in a text editor and enter applicable database information.
Next, open config.php in a text-editor. In the 'database' field, enter in the database type you are using. Currently, only Mysql is supported (see below for information about other database types). If you wish, you can change the charset in the 'connections' field, but the default 'utf8' should satisfy most people. That should be all you have to do. The other information in the file is pulled in from the .env file you setup in the previous step.
Other database types
The database connection uses php PDO drivers that can be changed out fairly easily. Currently, PDO supports 12 database types. Check the driver list for more information. If you wish to make an adapter for one of these database types, adapter name rules must be followed.
- Cuprid: CupridDatabase
- FreeTDS / Microsoft SQL Server / Sybase: DblibDatabase
- Firebird: FirebirdDatabase
- IBM DB2: IbmDatabase
- IBM Informix Dynamic Server: InformixDatabase
- MySQL: MysqlDatabase
- Oracle Call Interface: OciDatabase
- ODBC v3 (IBM DB2, unixODBC and win32 ODBC): OdbcDatabase
- PostgreSQL: PgsqlDatabase
- SQLite 3 and SQLite 2: SqliteDatabase
- Microsoft SQL Server / SQL Azure: SqlsrvDatabase
- 4d: FourD (A class naming rule exception exists for this, but it is untested)
The adapter class should be in its own file in src/Database/Databases/ and must implement DatabaseInterface. If you make a new adapter, please let me know so I can include it in the main program. If you dont know how to write a new adapter, let me know and Ill do it if time permits.
Besides making an adapter, you will also have to make a new array for the database in 'connections' in config.php.
All versions of pronounce-php with dependencies
symfony/filesystem Version ~2.0
phpunit/phpunit Version ~4.0
vlucas/phpdotenv Version ^2.0