# eric5.QScintilla.SpellChecker

Module implementing the spell checker for the editor component.

The spell checker is based on pyenchant.

### Global Attributes

None

### Classes

SpellChecker | Class implementing a pyenchant based spell checker.

### Functions

None

## SpellChecker

Class implementing a pyenchant based spell checker.

### Derived from

QObject

### Class Attributes

_spelling_dict
_spelling_lang

### Class Methods

_getDict | Protected classmethod to get a new dictionary.
getAvailableLanguages | Class method to get all available languages.
getDefaultPath | Class method to get the default path names of the user dictionaries.
getUserDictionaryPath | Class method to get the path name of a user dictionary file.
isAvailable | Class method to check, if spellchecking is available.
setDefaultLanguage | Class method to set the default language.

### Methods

SpellChecker | Constructor
__checkDocumentPart | Private method to check some part of the document.
__getNextWord | Private method to get the next word in the text after the given position.
__incrementalCheck | Private method to check the document incrementally.
__iter__ | Special method to create an iterator.
__next__ | Special method to advance to the next error.
add | Public method to add a word to the personal word list.
checkCurrentPage | Public method to check the currently visible page.
checkDocument | Public method to check the complete document.
checkDocumentIncrementally | Public method to check the document incrementally.
checkLines | Public method to check some lines of text.
checkSelection | Public method to check the current selection.
checkWord | Public method to check the word at position pos.
clearAll | Public method to clear all spelling markers.
getContext | Public method to get the context of a faulty word.
getError | Public method to get information about the last error found.
getLanguage | Public method to get the current language.
getSuggestions | Public method to get suggestions for the given word.
ignoreAlways | Public method to tell the checker, to always ignore the given word or the current word.
initCheck | Public method to initialize a spell check.
next | Public method to advance to the next error.
remove | Public method to add a word to the personal exclude list.
replace | Public method to tell the checker to replace the current word with the replacement string.
replaceAlways | Public method to tell the checker to always replace the current word with the replacement string.
setLanguage | Public method to set the current language.
setMinimumWordSize | Public method to set the minimum word size.
stopIncrementalCheck | Public method to stop an incremental check.

### Static Methods

None

#### SpellChecker._getDict (class method)

_getDict(lang, pwl="", pel="")

Protected classmethod to get a new dictionary.

lang
  the language to be used as the default (string). The string should be in language locale format (e.g. en_US, de).
pwl=
  name of the personal/project word list (string)
pel=
  name of the personal/project exclude list (string)

Returns:
  reference to the dictionary (enchant.Dict)

#### SpellChecker.getAvailableLanguages (class method)

getAvailableLanguages()

Class method to get all available languages.

Returns:
  list of available languages (list of strings)

#### SpellChecker.getDefaultPath (class method)

getDefaultPath(isException=False)

Class method to get the default path names of the user dictionaries.

isException
  flag indicating to return the name of the default exception dictionary (boolean)

Returns:
  file name of the default user dictionary or the default user exception dictionary (string)

#### SpellChecker.getUserDictionaryPath (class method)

getUserDictionaryPath(isException=False)

Class method to get the path name of a user dictionary file.

isException
  flag indicating to return the name of the user exception dictionary (boolean)

Returns:
  file name of the user dictionary or the user exception dictionary (string)

#### SpellChecker.isAvailable (class method)

isAvailable()

Class method to check, if spellchecking is available.

Returns:
  flag indicating availability (boolean)

#### SpellChecker.setDefaultLanguage (class method)

setDefaultLanguage(language)

Class method to set the default language.

language
  the language to be used as the default (string). The string should be in language locale format (e.g. en_US, de).

#### SpellChecker (Constructor)

SpellChecker(editor, indicator, defaultLanguage=None, checkRegion=None)

Constructor

editor
  reference to the editor object (QScintilla.Editor)
indicator
  spell checking indicator
defaultLanguage=
  the language to be used as the default (string). The string should be in language locale format (e.g. en_US, de).
checkRegion=
  reference to a function to check for a valid region

#### SpellChecker.__checkDocumentPart

__checkDocumentPart(startPos, endPos)

Private method to check some part of the document.

startPos
  position to start at (integer)
endPos
  position to end at (integer)

#### SpellChecker.__getNextWord

__getNextWord(pos, endPosition)

Private method to get the next word in the text after the given position.

pos
  position to start word extraction (integer)
endPosition
  position to stop word extraction (integer)

Returns:
  tuple of three values (the extracted word (string), start position (integer), end position (integer))

#### SpellChecker.__incrementalCheck

__incrementalCheck()

Private method to check the document incrementally.

#### SpellChecker.__iter__

__iter__()

Special method to create an iterator.

Returns:
  self

#### SpellChecker.__next__

__next__()

Special method to advance to the next error.

Returns:
  self

Raises StopIteration:
  raised to indicate the end of the iteration

#### SpellChecker.add

add(word=None)

Public method to add a word to the personal word list.

word
  word to add (string)

#### SpellChecker.checkCurrentPage

checkCurrentPage()

Public method to check the currently visible page.

#### SpellChecker.checkDocument

checkDocument()

Public method to check the complete document.

#### SpellChecker.checkDocumentIncrementally

checkDocumentIncrementally()

Public method to check the document incrementally.

#### SpellChecker.checkLines

checkLines(firstLine, lastLine)

Public method to check some lines of text.

firstLine
  line number of first line to check (integer)
lastLine
  line number of last line to check (integer)

#### SpellChecker.checkSelection

checkSelection()

Public method to check the current selection.

#### SpellChecker.checkWord

checkWord(pos, atEnd=False)

Public method to check the word at position pos.

pos
  position to check at (integer)
atEnd=
  flag indicating the position is at the end of the word to check (boolean)

#### SpellChecker.clearAll

clearAll()

Public method to clear all spelling markers.

#### SpellChecker.getContext

getContext(wordStart, wordEnd)

Public method to get the context of a faulty word.

wordStart
  the starting position of the word (integer)
wordEnd
  the ending position of the word (integer)

Returns:
  tuple of the leading and trailing context (string, string)

#### SpellChecker.getError

getError()

Public method to get information about the last error found.

Returns:
  tuple of last faulty word (string), starting position of the faulty word (integer) and ending position of the faulty word (integer)

#### SpellChecker.getLanguage

getLanguage()

Public method to get the current language.

Returns:
  current language in language locale format (string)

#### SpellChecker.getSuggestions

getSuggestions(word)

Public method to get suggestions for the given word.

word
  word to get suggestions for (string)

Returns:
  list of suggestions (list of strings)

#### SpellChecker.ignoreAlways

ignoreAlways(word=None)

Public method to tell the checker, to always ignore the given word or the current word.

word
  word to be ignored (string)

#### SpellChecker.initCheck

initCheck(startPos, endPos)

Public method to initialize a spell check.

startPos
  position to start at (integer)
endPos
  position to end at (integer)

Returns:
  flag indicating successful initialization (boolean)

#### SpellChecker.next

next()

Public method to advance to the next error.

Returns:
  self

#### SpellChecker.remove

remove(word)

Public method to add a word to the personal exclude list.

word
  word to add (string)

#### SpellChecker.replace

replace(replacement)

Public method to tell the checker to replace the current word with the replacement string.

replacement
  replacement string (string)

#### SpellChecker.replaceAlways

replaceAlways(replacement)

Public method to tell the checker to always replace the current word with the replacement string.

replacement
  replacement string (string)

#### SpellChecker.setLanguage

setLanguage(language, pwl="", pel="")

Public method to set the current language.

language
  the language to be used as the default (string). The string should be in language locale format (e.g. en_US, de).
pwl=
  name of the personal/project word list (string)
pel=
  name of the personal/project exclude list (string)

#### SpellChecker.setMinimumWordSize

setMinimumWordSize(size)

Public method to set the minimum word size.

size
  minimum word size (integer)

#### SpellChecker.stopIncrementalCheck

stopIncrementalCheck()

Public method to stop an incremental check.

Up