Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"packages": [ | ||
"packages/*", | ||
"rfc/*", | ||
"test-packages/*", | ||
"integration-tests" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Suggestion Lists | ||
|
||
## Flag Words | ||
|
||
The idea is to enhance the definition of `flagWords` to allow for suggestions. | ||
|
||
### Type Definitions | ||
|
||
Replace the definition of `flagWords` with the following: | ||
|
||
```ts | ||
type FlagWordNoSuggestions = string; | ||
type FlagWordWithSuggestions = [forbidWord: string, suggestion: string, ...otherSuggestions: string[]]; | ||
type FlagWord = FlagWordNoSuggestions | FlagWordWithSuggestions; | ||
type FlagWords = FlagWord[]; | ||
|
||
interface BaseSettings { | ||
// ... other fields | ||
flagWords?: FlagWords; | ||
} | ||
``` | ||
|
||
### Usage: | ||
|
||
```yaml | ||
flagWords: | ||
- crap | ||
- [hte, the] | ||
- [acadmic, academic] | ||
- [accension, accession, ascension] | ||
``` | ||
|
||
```json | ||
"flagWords": [ | ||
"crap", | ||
["hte", "the"], | ||
["acadmic", "academic"], | ||
["accension", "accession", "ascension"] | ||
] | ||
``` | ||
|
||
## Suggestion Dictionary | ||
|
||
Be able to leverage lists like: | ||
|
||
- [Wikipedia:Lists of common misspellings/For machines - Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines) | ||
|
||
Using a suggestions dictionary provides several useful features: | ||
|
||
- The word list is in a separate file | ||
- Multiple formats can be supported | ||
- Named dictionaries can be turned on, off, or even redefined | ||
|
||
### File formats | ||
|
||
The file format is generally inferred based upon the file extension. All files can be `gzip`d and will have a `.gz` final extension. | ||
|
||
#### Text File Format | ||
|
||
One suggestion set per line. | ||
|
||
Example: | ||
|
||
<!--- cspell:disable --> | ||
|
||
```txt | ||
againnst->against | ||
agains->against | ||
agaisnt -> against | ||
aganist-> against | ||
aggaravates->aggravates | ||
alusion->allusion, illusion | ||
alwasy->always | ||
alwyas->always | ||
amalgomated->amalgamated | ||
amatuer->amateur | ||
amature->armature, amateur | ||
boaut->boat, bout, about | ||
``` | ||
|
||
Validation: | ||
|
||
```regexp | ||
/^(\p{L}+)\s*->\s*(\p{L}+)(?:,\s*(\p{L}+))*$/gmu | ||
``` | ||
|
||
![image](https://user-images.githubusercontent.com/3740137/149126237-455c6674-ed1f-4dd8-8136-083531d2c63b.png) | ||
|
||
<!--- cspell:enable --> | ||
|
||
<!--- cspell:ignore acadmic accension --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('../../jest.config'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "rfc-0001-suggestions", | ||
"version": "1.0.0", | ||
"description": "Possible ways to support suggestion lists", | ||
"private": true, | ||
"scripts": { | ||
"build": "tsc -p .", | ||
"test": "" | ||
}, | ||
"files": [], | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@cspell/cspell-types": "^5.15.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { DictionaryDefinitionPreferred, BaseSetting } from '@cspell/cspell-types'; | ||
|
||
export interface DictionaryDefinitionSuggestions extends Omit<DictionaryDefinitionPreferred, 'type'> { | ||
type: 'suggestions'; | ||
} | ||
|
||
const exampleDef: DictionaryDefinitionSuggestions = { | ||
name: 'en-us-suggestions', | ||
path: './en-suggestions.txt.gz', | ||
type: 'suggestions', | ||
}; | ||
|
||
/*********************/ | ||
|
||
type FlagWordNoSuggestions = string; | ||
type FlagWordWithSuggestions = [forbidWord: string, suggestion: string, ...otherSuggestions: string[]]; | ||
type FlagWord = FlagWordNoSuggestions | FlagWordWithSuggestions; | ||
export type FlagWords = FlagWord[]; | ||
|
||
// Changes to BaseSettings: | ||
export interface NewBaseSettings extends Omit<BaseSetting, 'flagWords'> { | ||
flagWords?: FlagWords; | ||
} | ||
|
||
const exampleFlagWords: NewBaseSettings = { | ||
flagWords: ['crap', ['hte', 'the']], | ||
}; | ||
|
||
/*********************/ | ||
|
||
export const __testing__ = { | ||
exampleDef, | ||
exampleFlagWords, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
}, | ||
"include": [ | ||
"src/**/*.ts", | ||
"src/**/*.test.ts" | ||
] | ||
} |