Mercurial > hg > rc2
comparison program/lib/Roundcube/rcube_spellcheck_engine.php @ 0:4681f974d28b
vanilla 1.3.3 distro, I hope
| author | Charlie Root |
|---|---|
| date | Thu, 04 Jan 2018 15:52:31 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:4681f974d28b |
|---|---|
| 1 <?php | |
| 2 | |
| 3 /** | |
| 4 +-----------------------------------------------------------------------+ | |
| 5 | This file is part of the Roundcube Webmail client | | |
| 6 | | | |
| 7 | Copyright (C) 2011-2013, Kolab Systems AG | | |
| 8 | Copyright (C) 2008-2013, The Roundcube Dev Team | | |
| 9 | | | |
| 10 | Licensed under the GNU General Public License version 3 or | | |
| 11 | any later version with exceptions for skins & plugins. | | |
| 12 | See the README file for a full license statement. | | |
| 13 | | | |
| 14 | PURPOSE: | | |
| 15 | Interface class for a spell-checking backend | | |
| 16 +-----------------------------------------------------------------------+ | |
| 17 | Author: Thomas Bruederli <roundcube@gmail.com> | | |
| 18 +-----------------------------------------------------------------------+ | |
| 19 */ | |
| 20 | |
| 21 /** | |
| 22 * Interface class for a spell-checking backend | |
| 23 * | |
| 24 * @package Framework | |
| 25 * @subpackage Utils | |
| 26 */ | |
| 27 abstract class rcube_spellcheck_engine | |
| 28 { | |
| 29 const MAX_SUGGESTIONS = 10; | |
| 30 | |
| 31 protected $lang; | |
| 32 protected $error; | |
| 33 protected $dictionary; | |
| 34 protected $separator = '/[\s\r\n\t\(\)\/\[\]{}<>\\"]+|[:;?!,\.](?=\W|$)/'; | |
| 35 | |
| 36 /** | |
| 37 * Default constructor | |
| 38 */ | |
| 39 public function __construct($dict, $lang) | |
| 40 { | |
| 41 $this->dictionary = $dict; | |
| 42 $this->lang = $lang; | |
| 43 } | |
| 44 | |
| 45 /** | |
| 46 * Return a list of languages supported by this backend | |
| 47 * | |
| 48 * @return array Indexed list of language codes | |
| 49 */ | |
| 50 abstract function languages(); | |
| 51 | |
| 52 /** | |
| 53 * Set content and check spelling | |
| 54 * | |
| 55 * @param string $text Text content for spellchecking | |
| 56 * | |
| 57 * @return bool True when no mispelling found, otherwise false | |
| 58 */ | |
| 59 abstract function check($text); | |
| 60 | |
| 61 /** | |
| 62 * Returns suggestions for the specified word | |
| 63 * | |
| 64 * @param string $word The word | |
| 65 * | |
| 66 * @return array Suggestions list | |
| 67 */ | |
| 68 abstract function get_suggestions($word); | |
| 69 | |
| 70 /** | |
| 71 * Returns misspelled words | |
| 72 * | |
| 73 * @param string $text The content for spellchecking. If empty content | |
| 74 * used for check() method will be used. | |
| 75 * | |
| 76 * @return array List of misspelled words | |
| 77 */ | |
| 78 abstract function get_words($text = null); | |
| 79 | |
| 80 /** | |
| 81 * Returns error message | |
| 82 * | |
| 83 * @return string Error message | |
| 84 */ | |
| 85 public function error() | |
| 86 { | |
| 87 return $this->error; | |
| 88 } | |
| 89 } |
