enchant_broker_describe

Enumerates the Enchant providers

说明

array enchant_broker_describe ( resource $broker )

Enumerates the Enchant providers and tells you some rudimentary information about them. The same info is provided through phpinfo().

参数

broker
Broker resource

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 List the backends provided by the given broker

<?php
$r = enchant_broker_init();
$bprovides = enchant_broker_describe($r);
echo "Current broker provides the following backend(s):\n";
print_r($bprovides);

?>

以上例程的输出类似于:

Current broker provides the following backend(s):
Array
(
    [0] => Array
        (
            [name] => aspell
            [desc] => Aspell Provider
            [file] => /usr/lib/enchant/libenchant_aspell.so
        )

    [1] => Array
        (
            [name] => hspell
            [desc] => Hspell Provider
            [file] => /usr/lib/enchant/libenchant_hspell.so
        )

    [2] => Array
        (
            [name] => ispell
            [desc] => Ispell Provider
            [file] => /usr/lib/enchant/libenchant_ispell.so
        )

    [3] => Array
        (
            [name] => myspell
            [desc] => Myspell Provider
            [file] => /usr/lib/enchant/libenchant_myspell.so
        )

)

enchant_broker_dict_exists

Whether a dictionary exists or not. Using non-empty tag

说明

bool enchant_broker_dict_exists ( resource $broker , string $tag )

Tells if a dictionary exists or not, using a non-empty tags

参数

broker
Broker resource

tag
non-empty tag in the LOCALE format, ex: us_US, ch_DE, etc.

返回值

Returns TRUE when the tag exist or FALSE when not.

范例

示例 #1 A enchant_broker_dict_exists example

<?php
$tag = 'en_US';
$r = enchant_broker_init();
if (enchant_broker_dict_exists($r,$tag)) {
    echo $tag . " dictionary found.\n";
}
?>

参见

  • enchant_broker_describe

enchant_broker_free_dict

Free a dictionary resource

说明

bool enchant_broker_free_dict ( resource $dict )

Free a dictionary resource.

参数

dict
Dictionary resource.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • enchant_broker_request_dict
  • enchant_broker_request_pwl_dict

enchant_broker_free

Free the broker resource and its dictionaries

说明

bool enchant_broker_free ( resource $broker )

Free a broker resource with all its dictionaries.

参数

broker
Broker resource

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • enchant_broker_init

enchant_broker_get_dict_path

Get the directory path for a given backend

说明

bool enchant_broker_get_dict_path ( resource $broker , int $dict_type )

Get the directory path for a given backend.

参数

broker
Broker resource.

dict_type
The type of the dictionaries, i.e. ENCHANT_MYSPELL or ENCHANT_ISPELL.

返回值

Returns the path of the dictionary directory on success 或者在失败时返回 FALSE.

参见

  • enchant_broker_set_dict_path

enchant_broker_get_error

Returns the last error of the broker

说明

string enchant_broker_get_error ( resource $broker )

Returns the last error which occurred in this broker.

参数

broker
Broker resource.

返回值

Return the msg string if an error was found or FALSE

enchant_broker_init

Create a new broker object capable of requesting

说明

resource enchant_broker_init ( void )

参数

返回值

Returns a broker resource on success or FALSE.

参见

  • enchant_broker_free

enchant_broker_list_dicts

Returns a list of available dictionaries

说明

mixed enchant_broker_list_dicts ( resource $broker )

Returns a list of available dictionaries with their details.

参数

broker
Broker resource

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 List all available dictionaries for one broker

<?php
$r = enchant_broker_init();
$dicts = enchant_broker_list_dicts($r);
print_r($dicts);
?>

以上例程的输出类似于:

Array
(
    [0] => Array
        (
            [lang_tag] => de
            [provider_name] => aspell
            [provider_desc] => Aspell Provider
            [provider_file] => /usr/lib/enchant/libenchant_aspell.so
        )

    [1] => Array
        (
            [lang_tag] => de_DE
            [provider_name] => aspell
            [provider_desc] => Aspell Provider
            [provider_file] => /usr/lib/enchant/libenchant_aspell.so
        )

    [3] => Array
        (
            [lang_tag] => en
            [provider_name] => aspell
            [provider_desc] => Aspell Provider
            [provider_file] => /usr/lib/enchant/libenchant_aspell.so
        )

    [4] => Array
        (
            [lang_tag] => en_GB
            [provider_name] => aspell
            [provider_desc] => Aspell Provider
            [provider_file] => /usr/lib/enchant/libenchant_aspell.so
        )

    [5] => Array
        (
            [lang_tag] => en_US
            [provider_name] => aspell
            [provider_desc] => Aspell Provider
            [provider_file] => /usr/lib/enchant/libenchant_aspell.so
        )

    [6] => Array
        (
            [lang_tag] => hi_IN
            [provider_name] => myspell
            [provider_desc] => Myspell Provider
            [provider_file] => /usr/lib/enchant/libenchant_myspell.so
        )

)

参见

  • enchant_broker_describe

enchant_broker_request_dict

Create a new dictionary using a tag

说明

resource enchant_broker_request_dict ( resource $broker , string $tag )

create a new dictionary using tag, the non-empty language tag you wish to request a dictionary for ("en_US", "de_DE", ...)

参数

broker
Broker resource

tag
A tag describing the locale, for example en_US, de_DE

返回值

Returns a dictionary resource on success 或者在失败时返回 FALSE.

范例

示例 #1 A enchant_broker_request_dict example

Check if a dictionary exists using enchant_broker_dict_exists and request it.

<?php
$tag = 'en_US';
$broker = enchant_broker_init();
if (enchant_broker_dict_exists($broker,$tag)) {
    $dict = enchant_broker_request_dict($r, $tag);
}
?>

参见

  • enchant_dict_describe
  • enchant_broker_dict_exists
  • enchant_broker_free_dict

enchant_broker_request_pwl_dict

Creates a dictionary using a PWL file

说明

resource enchant_broker_request_pwl_dict ( resource $broker , string $filename )

Creates a dictionary using a PWL file. A PWL file is personal word file one word per line.

参数

broker
Broker resource

filename
Path to the PWL file. If there is no such file, a new one will be created if possible.

返回值

Returns a dictionary resource on success 或者在失败时返回 FALSE.

参见

  • enchant_dict_describe
  • enchant_broker_dict_exists
  • enchant_broker_free_dict

enchant_broker_set_dict_path

Set the directory path for a given backend

说明

bool enchant_broker_set_dict_path ( resource $broker , int $dict_type , string $value )

Set the directory path for a given backend.

参数

broker
Broker resource.

dict_type
The type of the dictionaries, i.e. ENCHANT_MYSPELL or ENCHANT_ISPELL.

value
The path of the dictionary directory.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • enchant_broker_get_dict_path

enchant_broker_set_ordering

Declares a preference of dictionaries to use for the language

说明

bool enchant_broker_set_ordering ( resource $broker , string $tag , string $ordering )

Declares a preference of dictionaries to use for the language described/referred to by 'tag'. The ordering is a comma delimited list of provider names. As a special exception, the "*" tag can be used as a language tag to declare a default ordering for any language that does not explicitly declare an ordering.

参数

broker
Broker resource

tag
Language tag. The special "*" tag can be used as a language tag to declare a default ordering for any language that does not explicitly declare an ordering.

ordering
Comma delimited list of provider names

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

enchant_dict_add_to_personal

Add a word to personal word list

说明

void enchant_dict_add_to_personal ( resource $dict , string $word )

Add a word to personal word list of the given dictionary.

参数

dict
Dictionary resource

word
The word to add

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

示例 #1 Adding a word to a PWL

<?php

$filename = './my_word_list.pwl';
$word = 'Supercalifragilisticexpialidocious';

$broker = enchant_broker_init();
$dict = enchant_broker_request_pwl_dict($broker, $filename);

enchant_dict_add_to_personal($dict, $word);

enchant_broker_free($broker);

?>

参见

  • enchant_broker_request_pwl_dict
  • enchant_broker_request_dict

enchant_dict_add_to_session

Add 'word' to this spell-checking session

说明

void enchant_dict_add_to_session ( resource $dict , string $word )

Add a word to the given dictionary. It will be added only for the active spell-checking session.

参数

dict
Dictionary resource

word
The word to add

返回值

没有返回值。

参见

  • enchant_broker_request_dict

enchant_dict_check

Check whether a word is correctly spelled or not

说明

bool enchant_dict_check ( resource $dict , string $word )

If the word is correctly spelled return TRUE, otherwise return FALSE

参数

dict
Dictionary resource

word
The word to check

返回值

Returns TRUE if the word is spelled correctly, FALSE if not.

enchant_dict_describe

Describes an individual dictionary

说明

mixed enchant_dict_describe ( resource $dict )

Returns the details of the dictionary.

参数

dict
Dictionary resource

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 A enchant_dict_describe example

Check if a dictionary exists using enchant_broker_dict_exists and show the detail of it.

<?php
$tag = 'en_US';
$broker = enchant_broker_init();
if (enchant_broker_dict_exists($broker,$tag)) {
    $dict = enchant_broker_request_dict($r, $tag);
    $dict_details = enchant_dict_describe($dict);
    print_r($dict_details);
}
?>

以上例程的输出类似于:

Array
(
    [lang] => en_US
    [name] => aspell
    [desc] => Aspell Provider
    [file] => /usr/lib/enchant/libenchant_aspell.so
)

enchant_dict_get_error

Returns the last error of the current spelling-session

说明

string enchant_dict_get_error ( resource $dict )

Returns the last error of the current spelling-session

参数

dict
Dictinaray resource

返回值

Returns the error message as string or FALSE if no error occurred.

enchant_dict_is_in_session

Whether or not 'word' exists in this spelling-session

说明

bool enchant_dict_is_in_session ( resource $dict , string $word )

Tells whether or not a word already exists in the current session.

参数

dict
Dictionary resource

word
The word to lookup

返回值

Returns TRUE if the word exists or FALSE

参见

  • enchant_dict_add_to_session

enchant_dict_quick_check

Check the word is correctly spelled and provide suggestions

说明

bool enchant_dict_quick_check ( resource $dict , string $word [, array &$suggestions ] )

If the word is correctly spelled return TRUE, otherwise return FALSE, if suggestions variable is provided, fill it with spelling alternatives.

参数

dict
Dictionary resource

word
The word to check

suggestions
If the word is not correctly spelled, this variable will contain an array of suggestions.

返回值

Returns TRUE if the word is correctly spelled or FALSE

范例

示例 #1 A enchant_dict_quick_check example

<?php
$tag = 'en_US';
$r = enchant_broker_init();

if (enchant_broker_dict_exists($r,$tag)) {
    $d = enchant_broker_request_dict($r, $tag);
    enchant_dict_quick_check($d, 'soong', $suggs);
    print_r($suggs);
}
?>

以上例程的输出类似于:

Array
(
    [0] => song
    [1] => snog
    [2] => soon
    [3] => Sang
    [4] => Sung
    [5] => sang
    [6] => sung
    [7] => sponge
    [8] => spongy
    [9] => snag
    [10] => snug
    [11] => sonic
    [12] => sing
    [13] => songs
    [14] => Son
    [15] => Sonja
    [16] => Synge
    [17] => son
    [18] => Sejong
    [19] => sarong
    [20] => sooner
    [21] => Sony
    [22] => sown
    [23] => scone
    [24] => song's
)

参见

  • enchant_dict_check
  • enchant_dict_suggest

enchant_dict_store_replacement

Add a correction for a word

说明

void enchant_dict_store_replacement ( resource $dict , string $mis , string $cor )

Add a correction for 'mis' using 'cor'. Notes that you replaced @mis with @cor, so it's possibly more likely that future occurrences of @mis will be replaced with @cor. So it might bump @cor up in the suggestion list.

参数

dict
Dictionary resource

mis
The work to fix

cor
The correct word

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

enchant_dict_suggest

Will return a list of values if any of those pre-conditions are not met

说明

array enchant_dict_suggest ( resource $dict , string $word )

参数

dict
Dictionary resource

word
Word to use for the suggestions.

返回值

Will returns an array of suggestions if the word is bad spelled.

范例

示例 #1 A enchant_dict_suggest example

<?php
$tag = 'en_US';
$r = enchant_broker_init();
if (enchant_broker_dict_exists($r,$tag)) {
    $d = enchant_broker_request_dict($r, $tag);

    $wordcorrect = enchant_dict_check($d, "soong");
    if (!$wordcorrect) {
        $suggs = enchant_dict_suggest($d, "soong");
        echo "Suggestions for 'soong':";
        print_r($suggs);
    }
    enchant_broker_free_dict($d);
}
enchant_broker_free($r);
?>

参见

  • enchant_dict_check
  • enchant_dict_quick_check

目录