-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AI Assistant: Add ambiguous words to proofread features list (#38292)
* fix ts issues and add types * add ambiguous words feature * fix menu spacing * changelog
- Loading branch information
Showing
19 changed files
with
225 additions
and
68 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/plugins/jetpack/changelog/add-proofread-weasel-words
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,4 @@ | ||
Significance: patch | ||
Type: other | ||
|
||
AI Assistant: Add ambiguous words to proofread features list |
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
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
2 changes: 1 addition & 1 deletion
2
...tensions/plugins/ai-assistant-plugin/components/breve/dictionaries/dictionaries-config.js
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
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
34 changes: 34 additions & 0 deletions
34
...extensions/plugins/ai-assistant-plugin/components/breve/features/ambiguous-words/index.ts
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 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { escapeRegExp } from '../../utils/escapeRegExp'; | ||
import weaselWords from './words'; | ||
/** | ||
* Types | ||
*/ | ||
import type { BreveFeatureConfig, HighlightedWord } from '../../types'; | ||
|
||
export const AMBIGUOUS_WORDS: BreveFeatureConfig = { | ||
name: 'ambiguous-words', | ||
title: 'Ambiguous words', | ||
tagName: 'span', | ||
className: 'has-proofread-highlight--ambiguous-words', | ||
}; | ||
|
||
const list = new RegExp( `\\b(${ weaselWords.map( escapeRegExp ).join( '|' ) })\\b`, 'gi' ); | ||
|
||
export default function ambiguousWords( text: string ): Array< HighlightedWord > { | ||
const matches = text.matchAll( list ); | ||
const highlightedWords: Array< HighlightedWord > = []; | ||
|
||
for ( const match of matches ) { | ||
const word = match[ 0 ].trim(); | ||
highlightedWords.push( { | ||
word, | ||
startIndex: match.index, | ||
endIndex: match.index + word.length, | ||
} ); | ||
} | ||
|
||
return highlightedWords; | ||
} |
File renamed without changes.
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
File renamed without changes.
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
13 changes: 12 additions & 1 deletion
13
...plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/features/index.ts
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,12 +1,23 @@ | ||
/** | ||
* Features | ||
*/ | ||
import ambiguousWords, { AMBIGUOUS_WORDS } from './ambiguous-words'; | ||
import complexWords, { COMPLEX_WORDS } from './complex-words'; | ||
/** | ||
* Types | ||
*/ | ||
import type { BreveFeature } from '../types'; | ||
|
||
// Breve Highlights Features | ||
export default [ | ||
const features: Array< BreveFeature > = [ | ||
{ | ||
config: COMPLEX_WORDS, | ||
highlight: complexWords, | ||
}, | ||
{ | ||
config: AMBIGUOUS_WORDS, | ||
highlight: ambiguousWords, | ||
}, | ||
]; | ||
|
||
export default features; |
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
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
2 changes: 1 addition & 1 deletion
2
...gins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/highlight/style.scss
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
9 changes: 8 additions & 1 deletion
9
projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/index.ts
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
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
Oops, something went wrong.