Class: I2CE Hyphen (Development): Difference between revisions

From IHRIS Wiki
(Created page with '{{otherversions|Class: I2CE_Hyphen}} This article describes the class ''I2CE_Hyphen'' . *Location: Part of the module [[TextLayout Tools Module List (Development)#textlayout|text…')
 
No edit summary
 
Line 1: Line 1:
{{otherversions|Class: I2CE_Hyphen}}
{{otherversions|Class: I2CE_Hyphen}}
This article describes the class ''I2CE_Hyphen'' .
This article describes the class ''I2CE_Hyphen'' .
*Location: Part of the module [[TextLayout Tools Module List (Development)#textlayout|textlayout]] in the package [https://launchpad.net/textlayout TextLayout Tools] 4.0-dev
*Location: Part of the module [[TextLayout Tools Module List (Development)#textlayout|textlayout]] in the package [https://launchpad.net/textlayout TextLayout Tools] 4.1-dev
*Source: Defined in the file [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_Hyphen.php#L31 lib/I2CE_Hyphen.php] on line 31
*Source: Defined in the file [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_Hyphen.php#L31 lib/I2CE_Hyphen.php] on line 31
*Author: Carl Leitner <litlfred@ibiblio.org>
*Author: Carl Leitner <litlfred@ibiblio.org>
PHP  script implement Knuth's and Liang's hyphenation algorithm as described in  http://lingucomponent.openoffice.org/hyphenator.html In particular it uses the 'mashed up' dictionary files  Note: Internally, by default, all strings are encoded as UTF-8. This is highly recommended to enable the unicode preg to work quickly (without having to covert to UTF=8 and then back).  Note:  Does not (yet) support the non-standard hyphenation of hungarian, swedish, etc.
PHP  script implement Knuth's and Liang's hyphenation algorithm as described in  http://lingucomponent.openoffice.org/hyphenator.html In particular it uses the 'mashed up' dictionary files  Note: Internally, by default, all strings are encoded as UTF-8. This is highly recommended to enable the unicode preg to work quickly (without having to covert to UTF=8 and then back).  Note:  Does not (yet) support the non-standard hyphenation of hungarian, swedish, etc.
Line 8: Line 8:
===$enc===
===$enc===
protected @var I2CE_Encoding $enc the encoding used for internal storage of strings
protected @var I2CE_Encoding $enc the encoding used for internal storage of strings
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_Hyphen.php#L36 textlayout/lib/I2CE_Hyphen.php] on line 36
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_Hyphen.php#L36 textlayout/lib/I2CE_Hyphen.php] on line 36
*Type: protected $enc
*Type: protected $enc


===$patterns===
===$patterns===
An associative array contating the hyphenation patterns
An associative array contating the hyphenation patterns
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_Hyphen.php#L126 textlayout/lib/I2CE_Hyphen.php] on line 126
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_Hyphen.php#L126 textlayout/lib/I2CE_Hyphen.php] on line 126
*Type: protected  $patterns
*Type: protected  $patterns


===$trans===
===$trans===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_Hyphen.php#L127 textlayout/lib/I2CE_Hyphen.php] on line 127
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_Hyphen.php#L127 textlayout/lib/I2CE_Hyphen.php] on line 127
*Type: protected $trans
*Type: protected $trans


Line 23: Line 23:
===HyphenateWord()===
===HyphenateWord()===
Hyphenates a word according to the loaded dictionary
Hyphenates a word according to the loaded dictionary
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_Hyphen.php#L139 textlayout/lib/I2CE_Hyphen.php] on line 139
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_Hyphen.php#L139 textlayout/lib/I2CE_Hyphen.php] on line 139
*Signature: public function HyphenateWord($word,$supress)
*Signature: public function HyphenateWord($word,$supress)
*Parameters:
*Parameters:
Line 32: Line 32:
===LoadHyphenDictionary()===
===LoadHyphenDictionary()===
Load the hyphenation dictionary. The file is expected to be a 'mashed up' version of a .tex hyphenation dictionary geneareted by using substrings.pl as in the stand-along hyphenation code of http://lingucomponent.openoffice.org/hyphenator.html
Load the hyphenation dictionary. The file is expected to be a 'mashed up' version of a .tex hyphenation dictionary geneareted by using substrings.pl as in the stand-along hyphenation code of http://lingucomponent.openoffice.org/hyphenator.html
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_Hyphen.php#L55 textlayout/lib/I2CE_Hyphen.php] on line 55
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_Hyphen.php#L55 textlayout/lib/I2CE_Hyphen.php] on line 55
*Signature: public function LoadHyphenDictionary($file)
*Signature: public function LoadHyphenDictionary($file)
*Parameters:
*Parameters:
Line 38: Line 38:
===Visualize()===
===Visualize()===
Visualize a hyphenation for a word
Visualize a hyphenation for a word
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_Hyphen.php#L246 textlayout/lib/I2CE_Hyphen.php] on line 246
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_Hyphen.php#L249 textlayout/lib/I2CE_Hyphen.php] on line 249
*Signature: public function Visualize($word,$supress)
*Signature: public function Visualize($word,$supress)
*Parameters:
*Parameters:
Line 46: Line 46:
*Returns: [http://www.php.net/manual/en/language.types.string.php string ]<br/>the hyphenated word
*Returns: [http://www.php.net/manual/en/language.types.string.php string ]<br/>the hyphenated word
===__construct()===
===__construct()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_Hyphen.php#L42 textlayout/lib/I2CE_Hyphen.php] on line 42
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_Hyphen.php#L42 textlayout/lib/I2CE_Hyphen.php] on line 42
*Signature: public function __construct($enc)
*Signature: public function __construct($enc)
*Parameters:
*Parameters:
Line 52: Line 52:
===getWordParts()===
===getWordParts()===
Get the  parts of a word which breaks along hyphenation points or any non-letter.
Get the  parts of a word which breaks along hyphenation points or any non-letter.
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_Hyphen.php#L284 textlayout/lib/I2CE_Hyphen.php] on line 284
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_Hyphen.php#L287 textlayout/lib/I2CE_Hyphen.php] on line 287
*Signature: public function getWordParts($word,$supress)
*Signature: public function getWordParts($word,$supress)
*Parameters:
*Parameters:

Latest revision as of 08:15, 6 May 2015


This article describes the class I2CE_Hyphen .

PHP script implement Knuth's and Liang's hyphenation algorithm as described in http://lingucomponent.openoffice.org/hyphenator.html In particular it uses the 'mashed up' dictionary files Note: Internally, by default, all strings are encoded as UTF-8. This is highly recommended to enable the unicode preg to work quickly (without having to covert to UTF=8 and then back). Note: Does not (yet) support the non-standard hyphenation of hungarian, swedish, etc.

Variables

$enc

protected @var I2CE_Encoding $enc the encoding used for internal storage of strings

$patterns

An associative array contating the hyphenation patterns

$trans

Methods

HyphenateWord()

Hyphenates a word according to the loaded dictionary

  • Defined in textlayout/lib/I2CE_Hyphen.php on line 139
  • Signature: public function HyphenateWord($word,$supress)
  • Parameters:
    • string $word
      the word to be hyphenated WARNING the word is assumed to be only letters. if you need something more general see getWordParts()
    • bool $supress
      true (default)to suppress hyphenation points at the beginning/end of a word.
      • Default Value: true
  • Returns: array
    of int containing the hyphenation points. the hyphenation points are the offsets for begining of each subword. of course, 0 is a hyphenation point.

LoadHyphenDictionary()

Load the hyphenation dictionary. The file is expected to be a 'mashed up' version of a .tex hyphenation dictionary geneareted by using substrings.pl as in the stand-along hyphenation code of http://lingucomponent.openoffice.org/hyphenator.html

Visualize()

Visualize a hyphenation for a word

  • Defined in textlayout/lib/I2CE_Hyphen.php on line 249
  • Signature: public function Visualize($word,$supress)
  • Parameters:
    • string $word
      the word that is to be hyphenated WARNING the word is assumed to have no whitespace or periods and to be only one word no digits or other special characters (unless they are already in your hypehnation dictionary)
    • bool $supress
      true (default)to suppress hyphenation points at the beginning/end of a word.
      • Default Value: TRUE
  • Returns: string
    the hyphenated word

__construct()

  • Defined in textlayout/lib/I2CE_Hyphen.php on line 42
  • Signature: public function __construct($enc)
  • Parameters:
    • I2CE_Encoding $enc
      specify the encoding the internal storage of this hyphenation dictionaty to the specified encoding.

getWordParts()

Get the parts of a word which breaks along hyphenation points or any non-letter.

  • Defined in textlayout/lib/I2CE_Hyphen.php on line 287
  • Signature: public function getWordParts($word,$supress)
  • Parameters:
    • string $word
      the word we wish to break up
    • bool $supress
      true (default)to suppress hyphenation points at the beginning/end of a word.
      • Default Value: true
  • Returns: an
    the associative array has a string 'Subword' which tells what the subword is, the int 'Offset' tells where the subword started, the int 'Length' the length of the subword, and the boolean 'IsLetter' which tells us if the subword is a composed of letters (by the Unicode convention) or not.