Skip to content

Commit

Permalink
AI Assistant: Add A8c dictionary (#39105)
Browse files Browse the repository at this point in the history
* add a8c dictionary

* capital P dangit

* changelog

* fix import
  • Loading branch information
dhasilva authored Aug 27, 2024
1 parent 1673ba1 commit 5c493a4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

AI Assistant: Add A8c dictionary
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default `Automattic
Tumblr
WooCommerce
Jetpack
Simplenote
WPScan
Crowdsignal
Cloudup
Akismet
Longreads
Newspack
Gravatar
BuddyPress
bbPress
WordCamp
Automatticians
Automattician
Mullenweg`;
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import nspell from 'nspell';
* Internal dependencies
*/
import getDictionary from '../../utils/get-dictionary';
import a8c from './a8c';
/**
* Types
*/
Expand Down Expand Up @@ -105,6 +106,9 @@ export const getSpellChecker = ( { language = 'en' }: { language?: string } = {}
);
exceptions.forEach( exception => spellChecker.add( exception ) );

// Add the Automattic dictionary
spellChecker.personal( a8c );

spellCheckers[ language ] = spellChecker;

return spellCheckers[ language ];
Expand Down Expand Up @@ -154,10 +158,15 @@ export const suggestSpellingFixes = (
) => {
const spellChecker = getSpellChecker( { language } );

if ( ! spellChecker ) {
if ( ! spellChecker || ! text ) {
return [];
}

// capital_P_dangit
if ( text.toLocaleLowerCase() === 'wordpress' ) {
return [ 'WordPress' ];
}

const suggestions = spellChecker.suggest( text );

return suggestions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export type SpellChecker = {
correct: ( word: string ) => boolean;
suggest: ( word: string ) => Array< string >;
add: ( word: string ) => void;
personal: ( dic: string ) => void;
};

export type SpellingDictionaryContext = {
Expand Down

0 comments on commit 5c493a4

Please sign in to comment.