/** * @file This file is an Typescript adaptation of the Hypher library * @see {@link https://github.com/bramstein/hypher|Hypher GitHub project page} * @license * Copyright (c) 2011, Bram Stein * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ type Pattern = { [key: number]: string; }; interface Language { leftmin: number; rightmin: number; patterns: Pattern; exceptions?: string; charSubstitution?: { [key: string]: string; }; } interface TrieNode { _points?: number[]; [key: number]: TrieNode; } /** * @constructor * @param {!{patterns: !Object, leftmin: !number, rightmin: !number}} language The language pattern file. Compatible with Hyphenator.js. */ export declare class Hypher { trie: TrieNode; leftMin: number; rightMin: number; exceptions: { [key: string]: RegExp; }; charSubstitution: { [key: string]: string; }; constructor(language: Language); /** * Creates a trie from a language pattern. * @private * @param patternObject An object with language patterns. * @return An object trie. */ protected _createTrie(patternObject: Pattern): TrieNode; /** * Hyphenates a text. * * @param str The text to hyphenate. * @param minLength Minimum length of the text to hyphenate * @return The same text with soft hyphens inserted in the right positions. */ hyphenateText(str: string, minLength?: number): string; /** * Hyphenates a word. * * @param word The word to hyphenate * @param leftMin Minimum number of characters before a hyphen * @param rightMin Minimum number of characters after a hyphen * @return An array of word fragments indicating valid hyphenation points. */ hyphenate(word: string, leftMin?: number, rightMin?: number): string[]; } export {};