Public API
Classes
Corrector
Base class for Corrector, which is the component being tested.
Child classes should overwrite auto_correct()
, auto_complete()
,
resolve_swipe()
, and predict_next_word()
.
By default, the implementation for these methods is dummy : just return an empty list of candidates.
Source code in kebbie/correctors.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
auto_correct(context, keystrokes, word)
Method used for auto-correction. Given a context and a typed word, this method should return a list of possible candidates for correction.
Note that the typed word is given both as a plain string, and as a list of keystrokes. The child class overwriting this method can use either of them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context |
str
|
String representing the previously typed characters (the beginning of the sentence basically). |
required |
keystrokes |
List[Optional[Tuple[float, float]]]
|
List of positions (x and y coordinates) for each keystroke of the word being typed. |
required |
word |
str
|
Word being typed (corresponding to the keystrokes). |
required |
Returns:
Type | Description |
---|---|
List[str]
|
The list of correction candidates. |
Source code in kebbie/correctors.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
auto_complete(context, keystrokes, partial_word)
Method used for auto-completion. Given a context and a partially typed word, this method should return a list of possible candidates for completion.
Note that the typed word is given both as a plain string, and as a list of keystrokes. The child class overwriting this method can use either of them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context |
str
|
String representing the previously typed characters (the beginning of the sentence basically). |
required |
keystrokes |
List[Optional[Tuple[float, float]]]
|
List of positions (x and y coordinates) for each keystroke of the word being typed. |
required |
partial_word |
str
|
Partial word being typed (corresponding to the keystrokes). |
required |
Returns:
Type | Description |
---|---|
List[str]
|
The list of completion candidates. |
Source code in kebbie/correctors.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
resolve_swipe(context, swipe_gesture)
Method used for resolving a swipe gesture. Given a context and a swipe gesture, this method should return a list of possible candidates corresponding to this swipe gesture.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context |
str
|
String representing the previously typed characters (the beginning of the sentence basically). |
required |
swipe_gesture |
List[Tuple[float, float]]
|
List of positions (x and y coordinates) along the keyboard, representing the swipe gesture. |
required |
Returns:
Type | Description |
---|---|
List[str]
|
The list of swiped word candidates. |
Source code in kebbie/correctors.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
predict_next_word(context)
Method used for next-word prediction task. Given a context, this method should return a list of possible candidates for next-word.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context |
str
|
String representing the previously typed characters (the beginning of the sentence basically). |
required |
Returns:
Type | Description |
---|---|
List[str]
|
The list of next-word candidates. |
Source code in kebbie/correctors.py
91 92 93 94 95 96 97 98 99 100 101 102 |
|
profiled_auto_correct(*args, **kwargs)
Profiled (memory & runtime) version of auto_correct
method.
No need to overwrite this method, unless you want to specify a custom memory and/or runtime measure.
Returns:
Type | Description |
---|---|
List[str]
|
List of candidates returned from the profiled method. |
int
|
Memory consumption in bytes. |
int
|
Runtime in nano seconds. |
Source code in kebbie/correctors.py
104 105 106 107 108 109 110 111 112 113 114 115 |
|
profiled_auto_complete(*args, **kwargs)
Profiled (memory & runtime) version of auto_complete
method.
No need to overwrite this method, unless you want to specify a custom memory and/or runtime measure.
Returns:
Type | Description |
---|---|
List[str]
|
List of candidates returned from the profiled method. |
int
|
Memory consumption in bytes. |
int
|
Runtime in nano seconds. |
Source code in kebbie/correctors.py
117 118 119 120 121 122 123 124 125 126 127 128 |
|
profiled_resolve_swipe(*args, **kwargs)
Profiled (memory & runtime) version of resolve_swipe
method.
No need to overwrite this method, unless you want to specify a custom memory and/or runtime measure.
Returns:
Type | Description |
---|---|
List[str]
|
List of candidates returned from the profiled method. |
int
|
Memory consumption in bytes. |
int
|
Runtime in nano seconds. |
Source code in kebbie/correctors.py
130 131 132 133 134 135 136 137 138 139 140 141 |
|
profiled_predict_next_word(*args, **kwargs)
Profiled (memory & runtime) version of predict_next_word
method.
No need to overwrite this method, unless you want to specify a custom memory and/or runtime measure.
Returns:
Type | Description |
---|---|
List[str]
|
List of candidates returned from the profiled method. |
int
|
Memory consumption in bytes. |
int
|
Runtime in nano seconds. |
Source code in kebbie/correctors.py
143 144 145 146 147 148 149 150 151 152 153 154 |
|
Functions
evaluate(corrector, lang='en-US', custom_keyboard=None, dataset=None, track_mistakes=False, n_most_common_mistakes=N_MOST_COMMON_MISTAKES, n_proc=None, seed=DEFAULT_SEED, beta=DEFAULT_BETA)
Main function of the kebbie
framework, it evaluates the given
Corrector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
corrector |
Corrector
|
The corrector to evaluate. |
required |
lang |
str
|
Language to test. For now, only |
'en-US'
|
custom_keyboard |
Dict
|
If provided, instead of relying on the keyboard layout provided by default, uses the given keyboard layout. |
None
|
dataset |
Dict[str, List[str]]
|
Data to use for testing. It
should be a dictionary where the key is the name of the domain, and
the value is a list of sentences. If |
None
|
track_mistakes |
bool
|
If |
False
|
n_most_common_mistakes |
int
|
If |
N_MOST_COMMON_MISTAKES
|
n_proc |
int
|
Number of processes to use. If |
None
|
seed |
int
|
Seed to use for running the tests. |
DEFAULT_SEED
|
beta |
float
|
Beta to use for computing the F-beta score. |
DEFAULT_BETA
|
Raises:
Type | Description |
---|---|
UnsupportedLanguage
|
Exception raised if |
Returns:
Type | Description |
---|---|
Dict
|
The results, in a dictionary. |
Source code in kebbie/__init__.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
Exceptions
UnsupportedLanguage
Bases: Exception
Custom Exception when the required language is not supported.
Source code in kebbie/__init__.py
19 20 21 22 |
|