diff --git a/projects/plugins/jetpack/changelog/update-jetpack-ai-breve-a8c-dictionary b/projects/plugins/jetpack/changelog/update-jetpack-ai-breve-a8c-dictionary new file mode 100644 index 0000000000000..9c01f54e8372b --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-jetpack-ai-breve-a8c-dictionary @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +AI Assistant: Add A8c dictionary diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/features/spelling-mistakes/a8c.ts b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/features/spelling-mistakes/a8c.ts new file mode 100644 index 0000000000000..f4eb03738ded2 --- /dev/null +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/features/spelling-mistakes/a8c.ts @@ -0,0 +1,18 @@ +export default `Automattic +Tumblr +WooCommerce +Jetpack +Simplenote +WPScan +Crowdsignal +Cloudup +Akismet +Longreads +Newspack +Gravatar +BuddyPress +bbPress +WordCamp +Automatticians +Automattician +Mullenweg`; diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/features/spelling-mistakes/index.ts b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/features/spelling-mistakes/index.ts index 21166597ad972..7175586da3dfb 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/features/spelling-mistakes/index.ts +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/features/spelling-mistakes/index.ts @@ -9,6 +9,7 @@ import nspell from 'nspell'; * Internal dependencies */ import getDictionary from '../../utils/get-dictionary'; +import a8c from './a8c'; /** * Types */ @@ -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 ]; @@ -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; diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/types.ts b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/types.ts index e2cd804d24821..f2e152c4feaea 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/types.ts +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/types.ts @@ -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 = {