コード例 #1
0
ファイル: __init__.py プロジェクト: jbingel/pyenchant
 def cb_func(tag,name,desc,file):
     s = EnchantStr("")
     tag = s.decode(tag)
     name = s.decode(name)
     desc = s.decode(desc)
     file = s.decode(file)
     cb_result.append((tag,name,desc,file))
コード例 #2
0
ファイル: __init__.py プロジェクト: RobertShayne/VNR-Extras
 def add_to_pwl(self, word):
     """Add a word to the user's personal word list."""
     warnings.warn("Dict.add_to_pwl is deprecated, please use Dict.add",
                   category=DeprecationWarning)
     self._check_this()
     word = EnchantStr(word)
     _e.dict_add_to_pwl(self._this, word.encode())
コード例 #3
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def cb_func(tag,name,desc,file):
     s = EnchantStr("")
     tag = s.decode(tag)
     name = s.decode(name)
     desc = s.decode(desc)
     file = s.decode(file)
     cb_result.append((tag,name,desc,file))
コード例 #4
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def add_to_pwl(self,word):
     """Add a word to the user's personal word list."""
     warnings.warn("Dict.add_to_pwl is deprecated, please use Dict.add",
                   category=DeprecationWarning,stacklevel=2)
     self._check_this()
     word = EnchantStr(word)
     _e.dict_add_to_pwl(self._this,word.encode())
コード例 #5
0
 def is_in_session(self, word):
     """Check whether a word is in the session list."""
     warnings.warn("Dict.is_in_session is deprecated, "\
                   "please use Dict.is_added",
                   category=DeprecationWarning,stacklevel=2)
     self._check_this()
     word = EnchantStr(word)
     return _e.dict_is_in_session(self._this, word.encode())
コード例 #6
0
    def get_param(self, name):
        """Get the value of a named parameter on this broker.

        Parameters are used to provide runtime information to individual
        provider backends.  See the method 'set_param' for more details.
        """
        name = EnchantStr(name)
        return name.decode(_e.broker_get_param(self._this, name.encode()))
コード例 #7
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
    def get_param(self,name):
        """Get the value of a named parameter on this broker.

        Parameters are used to provide runtime information to individual
        provider backends.  See the method 'set_param' for more details.
        """
        name = EnchantStr(name)
        return name.decode(_e.broker_get_param(self._this,name.encode()))
コード例 #8
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def is_in_session(self,word):
     """Check whether a word is in the session list."""
     warnings.warn("Dict.is_in_session is deprecated, "\
                   "please use Dict.is_added",
                   category=DeprecationWarning,stacklevel=2)
     self._check_this()
     word = EnchantStr(word)
     return _e.dict_is_in_session(self._this,word.encode())
コード例 #9
0
 def suggest(self, word):
     """Suggest possible spellings for a word.
     
     This method tries to guess the correct spelling for a given
     word, returning the possibilities in a list.
     """
     self._check_this()
     word = EnchantStr(word)
     suggs = _e.dict_suggest(self._this, word.encode())
     return [word.decode(w) for w in suggs]
コード例 #10
0
ファイル: __init__.py プロジェクト: arkershaw/pyenchant
 def suggest(self,word):
     """Suggest possible spellings for a word.
     
     This method tries to guess the correct spelling for a given
     word, returning the possibilities in a list.
     """
     self._check_this()
     word = EnchantStr(word)
     suggs = _e.dict_suggest(self._this,word.encode())
     return [word.decode(w) for w in suggs]
コード例 #11
0
ファイル: __init__.py プロジェクト: jbingel/pyenchant
    def dict_exists(self,tag):
        """Check availability of a dictionary.

        This method checks whether there is a dictionary available for
        the language specified by 'tag'.  It returns True if a dictionary
        is available, and False otherwise.
        """
        self._check_this()
        tag = EnchantStr(tag)
        val = _e.broker_dict_exists(self._this,tag.encode())
        return bool(val)
コード例 #12
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
    def set_param(self,name,value):
        """Set the value of a named parameter on this broker.

        Parameters are used to provide runtime information to individual
        provider backends.  For example, the myspell provider will search
        any directories given in the "enchant.myspell.dictionary.path"
        parameter when looking for its dictionary files.
        """
        name = EnchantStr(name)
        value = EnchantStr(value)
        _e.broker_set_param(self._this,name.encode(),value.encode())
コード例 #13
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def dict_exists(self,tag):
     """Check availability of a dictionary.
     
     This method checks whether there is a dictionary available for
     the language specified by 'tag'.  It returns True if a dictionary
     is available, and False otherwise.
     """
     self._check_this()
     tag = EnchantStr(tag)
     val = _e.broker_dict_exists(self._this,tag.encode())
     return bool(val)
コード例 #14
0
ファイル: __init__.py プロジェクト: jbingel/pyenchant
    def __describe_callback(self,name,desc,file):
        """Collector callback for dictionary description.

        This method is used as a callback into the _enchant function
        'enchant_broker_describe'.  It collects the given arguments in
        a tuple and appends them to the list '__describe_result'.
        """
        s = EnchantStr("")
        name = s.decode(name)
        desc = s.decode(desc)
        file = s.decode(file)
        self.__describe_result.append((name,desc,file))
コード例 #15
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def __describe_callback(self,name,desc,file):
     """Collector callback for dictionary description.
     
     This method is used as a callback into the _enchant function
     'enchant_broker_describe'.  It collects the given arguments in
     a tuple and appends them to the list '__describe_result'.
     """
     s = EnchantStr("")
     name = s.decode(name)
     desc = s.decode(desc)
     file = s.decode(file)
     self.__describe_result.append((name,desc,file))
コード例 #16
0
ファイル: __init__.py プロジェクト: obengwilliam/searchjob
 def store_replacement(self, mis, cor):
     """Store a replacement spelling for a miss-spelled word.
     
     This method makes a suggestion to the spellchecking engine that the 
     miss-spelled word <mis> is in fact correctly spelled as <cor>.  Such
     a suggestion will typically mean that <cor> appears early in the
     list of suggested spellings offered for later instances of <mis>.
     """
     self._check_this()
     mis = EnchantStr(mis)
     cor = EnchantStr(cor)
     _e.dict_store_replacement(self._this, mis.encode(), cor.encode())
コード例 #17
0
ファイル: __init__.py プロジェクト: jbingel/pyenchant
    def set_param(self,name,value):
        """Set the value of a named parameter on this broker.

        Parameters are used to provide runtime information to individual
        provider backends.  For example, the myspell provider will search
        any directories given in the "enchant.myspell.dictionary.path"
        parameter when looking for its dictionary files.
        """
        name = EnchantStr(name).encode()
        if value is not None:
            value = EnchantStr(value).encode()
        _e.broker_set_param(self._this,name,value)
コード例 #18
0
ファイル: __init__.py プロジェクト: jbingel/pyenchant
    def __list_dicts_callback(self,tag,name,desc,file):
        """Collector callback for listing dictionaries.

        This method is used as a callback into the _enchant function
        'enchant_broker_list_dicts'.  It collects the given arguments into
        an appropriate tuple and appends them to '__list_dicts_result'.
        """
        s = EnchantStr("")
        tag = s.decode(tag)
        name = s.decode(name)
        desc = s.decode(desc)
        file = s.decode(file)
        self.__list_dicts_result.append((tag,(name,desc,file)))
コード例 #19
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def __list_dicts_callback(self,tag,name,desc,file):
     """Collector callback for listing dictionaries.
     
     This method is used as a callback into the _enchant function
     'enchant_broker_list_dicts'.  It collects the given arguments into
     an appropriate tuple and appends them to '__list_dicts_result'.
     """
     s = EnchantStr("")
     tag = s.decode(tag)
     name = s.decode(name)
     desc = s.decode(desc)
     file = s.decode(file)
     self.__list_dicts_result.append((tag,(name,desc,file)))
コード例 #20
0
ファイル: __init__.py プロジェクト: RobertShayne/VNR-Extras
    def _request_dict_data(self, tag):
        """Request raw C pointer data for a dictionary.

        This method call passes on the call to the C library, and does
        some internal bookkeeping.
        """
        self._check_this()
        tag = EnchantStr(tag)
        new_dict = _e.broker_request_dict(self._this, tag.encode())
        if new_dict is None:
            eStr = "Dictionary for language '%s' could not be found"
            self._raise_error(eStr % (tag, ), DictNotFoundError)
        return new_dict
コード例 #21
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def __describe_callback(self,tag,name,desc,file):
     """Collector callback for dictionary description.
     
     This method is used as a callback into the _enchant function
     'enchant_dict_describe'.  It collects the given arguments in
     a tuple and stores them in the attribute '__describe_result'.
     """
     s = EnchantStr("")
     tag = s.decode(tag)
     name = s.decode(name)
     desc = s.decode(desc)
     file = s.decode(file)
     self.__describe_result = (tag,name,desc,file)
コード例 #22
0
ファイル: __init__.py プロジェクト: arkershaw/pyenchant
    def _request_dict_data(self,tag):
        """Request raw C pointer data for a dictionary.

        This method call passes on the call to the C library, and does
        some internal bookkeeping.
        """
        self._check_this()
        tag = EnchantStr(tag)
        new_dict = _e.broker_request_dict(self._this,tag.encode())
        if new_dict is None:
            eStr = "Dictionary for language '%s' could not be found"
            self._raise_error(eStr % (tag,),DictNotFoundError)
        return new_dict
コード例 #23
0
ファイル: __init__.py プロジェクト: jbingel/pyenchant
    def __describe_callback(self,tag,name,desc,file):
        """Collector callback for dictionary description.

        This method is used as a callback into the _enchant function
        'enchant_dict_describe'.  It collects the given arguments in
        a tuple and stores them in the attribute '__describe_result'.
        """
        s = EnchantStr("")
        tag = s.decode(tag)
        name = s.decode(name)
        desc = s.decode(desc)
        file = s.decode(file)
        self.__describe_result = (tag,name,desc,file)
コード例 #24
0
 def check(self, word):
     """Check spelling of a word.
     
     This method takes a word in the dictionary language and returns
     True if it is correctly spelled, and false otherwise.
     """
     self._check_this()
     word = EnchantStr(word)
     val = _e.dict_check(self._this, word.encode())
     if val == 0:
         return True
     if val > 0:
         return False
     self._raise_error()
コード例 #25
0
ファイル: __init__.py プロジェクト: arkershaw/pyenchant
 def check(self,word):
     """Check spelling of a word.
     
     This method takes a word in the dictionary language and returns
     True if it is correctly spelled, and false otherwise.
     """
     self._check_this()
     word = EnchantStr(word)
     val = _e.dict_check(self._this,word.encode())
     if val == 0:
         return True
     if val > 0:
         return False
     self._raise_error()
コード例 #26
0
 def suggest(self,word):
     """Suggest possible spellings for a word.
     
     This method tries to guess the correct spelling for a given
     word, returning the possibilities in a list.
     """
     self._check_this()
     word = EnchantStr(word)
     # Enchant asserts that the word is non-empty.
     # Check it up-front to avoid nasty warnings on stderr.
     if len(word) == 0:
         raise ValueError("can't suggest spellings for empty string")
     suggs = _e.dict_suggest(self._this,word.encode())
     return [word.decode(w) for w in suggs]
コード例 #27
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def suggest(self,word):
     """Suggest possible spellings for a word.
     
     This method tries to guess the correct spelling for a given
     word, returning the possibilities in a list.
     """
     self._check_this()
     word = EnchantStr(word)
     # Enchant asserts that the word is non-empty.
     # Check it up-front to avoid nasty warnings on stderr.
     if len(word) == 0:
         raise ValueError("can't suggest spellings for empty string")
     suggs = _e.dict_suggest(self._this,word.encode())
     return [word.decode(w) for w in suggs]
コード例 #28
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def set_ordering(self,tag,ordering):
     """Set dictionary preferences for a language.
     
     The Enchant library supports the use of multiple dictionary programs
     and multiple languages.  This method specifies which dictionaries
     the broker should prefer when dealing with a given language.  'tag'
     must be an appropriate language specification and 'ordering' is a
     string listing the dictionaries in order of preference.  For example
     a valid ordering might be "aspell,myspell,ispell".
     The value of 'tag' can also be set to "*" to set a default ordering
     for all languages for which one has not been set explicitly.
     """
     self._check_this()
     tag = EnchantStr(tag)
     ordering = EnchantStr(ordering)
     _e.broker_set_ordering(self._this,tag.encode(),ordering.encode())
コード例 #29
0
ファイル: __init__.py プロジェクト: RobertShayne/VNR-Extras
 def request_pwl_dict(self, pwl):
     """Request a Dict object for a personal word list.
     
     This method behaves as 'request_dict' but rather than returning
     a dictionary for a specific language, it returns a dictionary
     referencing a personal word list.  A personal word list is a file
     of custom dictionary entries, one word per line.
     """
     self._check_this()
     pwl = EnchantStr(pwl)
     new_dict = _e.broker_request_pwl_dict(self._this, pwl.encode())
     if new_dict is None:
         eStr = "Personal Word List file '%s' could not be loaded"
         self._raise_error(eStr % (pwl, ))
     d = Dict(False)
     d._switch_this(new_dict, self)
     return d
コード例 #30
0
ファイル: __init__.py プロジェクト: arkershaw/pyenchant
 def request_pwl_dict(self,pwl):
     """Request a Dict object for a personal word list.
     
     This method behaves as 'request_dict' but rather than returning
     a dictionary for a specific language, it returns a dictionary
     referencing a personal word list.  A personal word list is a file
     of custom dictionary entries, one word per line.
     """
     self._check_this()
     pwl = EnchantStr(pwl)
     new_dict = _e.broker_request_pwl_dict(self._this,pwl.encode())
     if new_dict is None:
         eStr = "Personal Word List file '%s' could not be loaded"
         self._raise_error(eStr % (pwl,))
     d = Dict(False)
     d._switch_this(new_dict,self)
     return d
コード例 #31
0
 def check(self,word):
     """Check spelling of a word.
     
     This method takes a word in the dictionary language and returns
     True if it is correctly spelled, and false otherwise.
     """
     self._check_this()
     word = EnchantStr(word)
     # Enchant asserts that the word is non-empty.
     # Check it up-front to avoid nasty warnings on stderr.
     if len(word) == 0:
         raise ValueError("can't check spelling of empty string")
     val = _e.dict_check(self._this,word.encode())
     if val == 0:
         return True
     if val > 0:
         return False
     self._raise_error()
コード例 #32
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def check(self,word):
     """Check spelling of a word.
     
     This method takes a word in the dictionary language and returns
     True if it is correctly spelled, and false otherwise.
     """
     self._check_this()
     word = EnchantStr(word)
     # Enchant asserts that the word is non-empty.
     # Check it up-front to avoid nasty warnings on stderr.
     if len(word) == 0:
         raise ValueError("can't check spelling of empty string")
     val = _e.dict_check(self._this,word.encode())
     if val == 0:
         return True
     if val > 0:
         return False
     self._raise_error()
コード例 #33
0
ファイル: __init__.py プロジェクト: RobertShayne/VNR-Extras
 def store_replacement(self, mis, cor):
     """Store a replacement spelling for a miss-spelled word.
     
     This method makes a suggestion to the spellchecking engine that the 
     miss-spelled word <mis> is in fact correctly spelled as <cor>.  Such
     a suggestion will typically mean that <cor> appears early in the
     list of suggested spellings offered for later instances of <mis>.
     """
     self._check_this()
     mis = EnchantStr(mis)
     cor = EnchantStr(cor)
     _e.dict_store_replacement(self._this, mis.encode(), cor.encode())
コード例 #34
0
ファイル: __init__.py プロジェクト: jbingel/pyenchant
    def set_ordering(self,tag,ordering):
        """Set dictionary preferences for a language.

        The Enchant library supports the use of multiple dictionary programs
        and multiple languages.  This method specifies which dictionaries
        the broker should prefer when dealing with a given language.  'tag'
        must be an appropriate language specification and 'ordering' is a
        string listing the dictionaries in order of preference.  For example
        a valid ordering might be "aspell,myspell,ispell".
        The value of 'tag' can also be set to "*" to set a default ordering
        for all languages for which one has not been set explicitly.
        """
        self._check_this()
        tag = EnchantStr(tag)
        ordering = EnchantStr(ordering)
        _e.broker_set_ordering(self._this,tag.encode(),ordering.encode())
コード例 #35
0
ファイル: __init__.py プロジェクト: jbingel/pyenchant
 def _raise_error(self,default="Unspecified Error",eclass=Error):
     """Overrides _EnchantObject._raise_error to check dict errors."""
     err = _e.dict_get_error(self._this)
     if err == "" or err is None:
         raise eclass(default)
     raise eclass(EnchantStr("").decode(err))
コード例 #36
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def is_removed(self,word):
     """Check whether a word is in the personal exclude list."""
     self._check_this()
     word = EnchantStr(word)
     return _e.dict_is_removed(self._this,word.encode())
コード例 #37
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def remove_from_session(self,word):
     """Add a word to the session exclude list."""
     self._check_this()
     word = EnchantStr(word)
     _e.dict_remove_from_session(self._this,word.encode())
コード例 #38
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def add_to_session(self,word):
     """Add a word to the session personal list."""
     self._check_this()
     word = EnchantStr(word)
     _e.dict_add_to_session(self._this,word.encode())
コード例 #39
0
 def add(self, word):
     """Add a word to the user's personal word list."""
     self._check_this()
     word = EnchantStr(word)
     _e.dict_add(self._this, word.encode())
コード例 #40
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def remove(self,word):
     """Add a word to the user's personal exclude list."""
     self._check_this()
     word = EnchantStr(word)
     _e.dict_remove(self._this,word.encode())
コード例 #41
0
ファイル: __init__.py プロジェクト: DKaman/pyenchant
 def add(self,word):
     """Add a word to the user's personal word list."""
     self._check_this()
     word = EnchantStr(word)
     _e.dict_add(self._this,word.encode())
コード例 #42
0
 def remove(self, word):
     """Add a word to the user's personal exclude list."""
     self._check_this()
     word = EnchantStr(word)
     _e.dict_remove(self._this, word.encode())
コード例 #43
0
 def add_to_session(self, word):
     """Add a word to the session personal list."""
     self._check_this()
     word = EnchantStr(word)
     _e.dict_add_to_session(self._this, word.encode())
コード例 #44
0
 def remove_from_session(self, word):
     """Add a word to the session exclude list."""
     self._check_this()
     word = EnchantStr(word)
     _e.dict_remove_from_session(self._this, word.encode())
コード例 #45
0
 def is_removed(self, word):
     """Check whether a word is in the personal exclude list."""
     self._check_this()
     word = EnchantStr(word)
     return _e.dict_is_removed(self._this, word.encode())