axyseo 2.0.0-alpha.0.0.55 → 2.0.0-alpha.0.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/languageProcessing/researches/getSentenceBeginnings.js +13 -12
- package/build/languageProcessing/researches/getSentenceBeginnings.js.map +1 -1
- package/build/languageProcessing/researches/wordCountInText.js +5 -4
- package/build/languageProcessing/researches/wordCountInText.js.map +1 -1
- package/build/scoring/assessments/seo/TextLengthAssessment.js +2 -2
- package/build/scoring/assessments/seo/TextLengthAssessment.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import getWords from "../helpers/word/getWords.js";
|
|
|
2
2
|
import getSentences from "../helpers/sentence/getSentences";
|
|
3
3
|
import stripSpaces from "../helpers/sanitize/stripSpaces.js";
|
|
4
4
|
import { stripFullTags as stripTags } from "../helpers/sanitize/stripHTMLTags.js";
|
|
5
|
-
import { filter, forEach, isEmpty } from
|
|
5
|
+
import { filter, forEach, isEmpty } from 'lodash';
|
|
6
6
|
import removeHtmlBlocks from "../helpers/html/htmlParser";
|
|
7
7
|
import { filterShortcodesFromHTML } from "../helpers";
|
|
8
8
|
|
|
@@ -60,16 +60,17 @@ const compareFirstWords = function (sentenceBeginnings, sentences) {
|
|
|
60
60
|
*/
|
|
61
61
|
function getSentenceBeginning(sentence, firstWordExceptions, secondWordExceptions, getWordsCustomHelper) {
|
|
62
62
|
const stripped = stripTags(stripSpaces(sentence));
|
|
63
|
-
|
|
63
|
+
let words = getWordsCustomHelper ? getWordsCustomHelper(stripped) : getWords(stripped);
|
|
64
|
+
words = words.filter(word => /^\p{L}/u.test(word));
|
|
64
65
|
if (words.length === 0) {
|
|
65
|
-
return
|
|
66
|
+
return '';
|
|
66
67
|
}
|
|
67
68
|
let firstWord = words[0].toLocaleLowerCase();
|
|
68
69
|
if (firstWordExceptions.indexOf(firstWord) > -1 && words.length > 1) {
|
|
69
|
-
firstWord = firstWord +
|
|
70
|
+
firstWord = firstWord + ' ' + words[1];
|
|
70
71
|
if (secondWordExceptions) {
|
|
71
72
|
if (secondWordExceptions.includes(words[1])) {
|
|
72
|
-
firstWord = firstWord +
|
|
73
|
+
firstWord = firstWord + ' ' + words[2];
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
}
|
|
@@ -85,22 +86,22 @@ function getSentenceBeginning(sentence, firstWordExceptions, secondWordException
|
|
|
85
86
|
* @returns {Object} The object containing the first word of each sentence and the corresponding counts.
|
|
86
87
|
*/
|
|
87
88
|
export default function (paper, researcher) {
|
|
88
|
-
const firstWordExceptions = researcher.getConfig(
|
|
89
|
-
const secondWordExceptions = researcher.getConfig(
|
|
90
|
-
const getWordsCustomHelper = researcher.getHelper(
|
|
91
|
-
const memoizedTokenizer = researcher.getHelper(
|
|
89
|
+
const firstWordExceptions = researcher.getConfig('firstWordExceptions');
|
|
90
|
+
const secondWordExceptions = researcher.getConfig('secondWordExceptions');
|
|
91
|
+
const getWordsCustomHelper = researcher.getHelper('getWordsCustomHelper');
|
|
92
|
+
const memoizedTokenizer = researcher.getHelper('memoizedTokenizer');
|
|
92
93
|
let text = paper.getText();
|
|
93
94
|
text = removeHtmlBlocks(text);
|
|
94
95
|
text = filterShortcodesFromHTML(text, paper._attributes && paper._attributes.shortcodes);
|
|
95
96
|
|
|
96
97
|
// Remove any HTML whitespace padding and replace it with a single whitespace.
|
|
97
|
-
text = text.replace(/[\s\n]+/g,
|
|
98
|
+
text = text.replace(/[\s\n]+/g, ' ');
|
|
98
99
|
|
|
99
100
|
// Exclude text inside tables.
|
|
100
|
-
text = text.replace(/<figure class='wp-block-table'>.*<\/figure>/
|
|
101
|
+
text = text.replace(/<figure class='wp-block-table'>.*<\/figure>/gs, '');
|
|
101
102
|
|
|
102
103
|
// Exclude text inside list items.
|
|
103
|
-
text = text.replace(/<li(?:[^>]+)?>(.*?)<\/li>/
|
|
104
|
+
text = text.replace(/<li(?:[^>]+)?>(.*?)<\/li>/gi, '');
|
|
104
105
|
let sentences = getSentences(text, memoizedTokenizer);
|
|
105
106
|
let sentenceBeginnings = sentences.map(function (sentence) {
|
|
106
107
|
return getSentenceBeginning(sentence, firstWordExceptions, secondWordExceptions, getWordsCustomHelper);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSentenceBeginnings.js","names":["getWords","getSentences","stripSpaces","stripFullTags","stripTags","filter","forEach","isEmpty","removeHtmlBlocks","filterShortcodesFromHTML","startsWithSameWord","currentSentenceBeginning","nextSentenceBeginning","compareFirstWords","sentenceBeginnings","sentences","consecutiveFirstWords","foundSentences","sameBeginnings","beginning","i","push","word","count","getSentenceBeginning","sentence","firstWordExceptions","secondWordExceptions","getWordsCustomHelper","stripped","words","length","firstWord","toLocaleLowerCase","indexOf","includes","paper","researcher","getConfig","getHelper","memoizedTokenizer","text","getText","_attributes","shortcodes","replace","map"],"sources":["../../../src/languageProcessing/researches/getSentenceBeginnings.js"],"sourcesContent":["import getWords from
|
|
1
|
+
{"version":3,"file":"getSentenceBeginnings.js","names":["getWords","getSentences","stripSpaces","stripFullTags","stripTags","filter","forEach","isEmpty","removeHtmlBlocks","filterShortcodesFromHTML","startsWithSameWord","currentSentenceBeginning","nextSentenceBeginning","compareFirstWords","sentenceBeginnings","sentences","consecutiveFirstWords","foundSentences","sameBeginnings","beginning","i","push","word","count","getSentenceBeginning","sentence","firstWordExceptions","secondWordExceptions","getWordsCustomHelper","stripped","words","test","length","firstWord","toLocaleLowerCase","indexOf","includes","paper","researcher","getConfig","getHelper","memoizedTokenizer","text","getText","_attributes","shortcodes","replace","map"],"sources":["../../../src/languageProcessing/researches/getSentenceBeginnings.js"],"sourcesContent":["import getWords from '../helpers/word/getWords.js';\nimport getSentences from '../helpers/sentence/getSentences';\nimport stripSpaces from '../helpers/sanitize/stripSpaces.js';\nimport {stripFullTags as stripTags} from '../helpers/sanitize/stripHTMLTags.js';\n\nimport {filter, forEach, isEmpty} from 'lodash';\nimport removeHtmlBlocks from '../helpers/html/htmlParser';\nimport {filterShortcodesFromHTML} from '../helpers';\n\n/**\n * Compares the first word of each sentence with the first word of the following sentence.\n *\n * @param {string} currentSentenceBeginning The first word of the current sentence.\n * @param {string} nextSentenceBeginning The first word of the next sentence.\n * @returns {boolean} Returns true if sentence beginnings match.\n */\nconst startsWithSameWord = function(currentSentenceBeginning, nextSentenceBeginning) {\n return !isEmpty(currentSentenceBeginning) && currentSentenceBeginning === nextSentenceBeginning;\n};\n\n/**\n * Counts the number of similar sentence beginnings.\n *\n * @param {Array} sentenceBeginnings The array containing the first word of each sentence.\n * @param {Array} sentences The array containing all sentences.\n * @returns {Array} The array containing the objects containing the first words and the corresponding counts.\n */\nconst compareFirstWords = function(sentenceBeginnings, sentences) {\n const consecutiveFirstWords = [];\n let foundSentences = [];\n let sameBeginnings = 1;\n\n forEach(sentenceBeginnings, function(beginning, i) {\n const currentSentenceBeginning = beginning;\n const nextSentenceBeginning = sentenceBeginnings[i + 1];\n foundSentences.push(sentences[i]);\n\n if (startsWithSameWord(currentSentenceBeginning, nextSentenceBeginning)) {\n sameBeginnings++;\n } else {\n consecutiveFirstWords.push({\n word: currentSentenceBeginning,\n count: sameBeginnings,\n sentences: foundSentences\n });\n sameBeginnings = 1;\n foundSentences = [];\n }\n });\n\n return consecutiveFirstWords;\n};\n\n/**\n * Retrieves the first word from the sentence. If the first or second word is on an exception list of words that should not be considered as sentence\n * beginnings, the following word is also retrieved.\n *\n * @param {string} sentence The sentence to retrieve the first word from.\n * @param {Array} firstWordExceptions First word exceptions to match against.\n * @param {Array} secondWordExceptions Second word exceptions to match against.\n * @param {function}\tgetWordsCustomHelper The language-specific helper function to retrieve words from text.\n *\n * @returns {string} The first word of the sentence.\n */\nfunction getSentenceBeginning(\n sentence,\n firstWordExceptions,\n secondWordExceptions,\n getWordsCustomHelper\n) {\n const stripped = stripTags(stripSpaces(sentence));\n let words = getWordsCustomHelper ? getWordsCustomHelper(stripped) : getWords(stripped);\n\n words = words.filter(word => /^\\p{L}/u.test(word));\n\n if (words.length === 0) {\n return '';\n }\n\n let firstWord = words[0].toLocaleLowerCase();\n\n if (firstWordExceptions.indexOf(firstWord) > -1 && words.length > 1) {\n firstWord = firstWord + ' ' + words[1];\n if (secondWordExceptions) {\n if (secondWordExceptions.includes(words[1])) {\n firstWord = firstWord + ' ' + words[2];\n }\n }\n }\n\n return firstWord;\n}\n\n/**\n * Gets the first word of each sentence from the text, and returns an object containing the first word of each sentence and the corresponding counts.\n *\n * @param {Paper} paper The Paper object to get the text from.\n * @param {Researcher} researcher The researcher this research is a part of.\n *\n * @returns {Object} The object containing the first word of each sentence and the corresponding counts.\n */\nexport default function(paper, researcher) {\n const firstWordExceptions = researcher.getConfig('firstWordExceptions');\n const secondWordExceptions = researcher.getConfig('secondWordExceptions');\n const getWordsCustomHelper = researcher.getHelper('getWordsCustomHelper');\n const memoizedTokenizer = researcher.getHelper('memoizedTokenizer');\n\n let text = paper.getText();\n text = removeHtmlBlocks(text);\n text = filterShortcodesFromHTML(text, paper._attributes && paper._attributes.shortcodes);\n\n // Remove any HTML whitespace padding and replace it with a single whitespace.\n text = text.replace(/[\\s\\n]+/g, ' ');\n\n // Exclude text inside tables.\n text = text.replace(/<figure class='wp-block-table'>.*<\\/figure>/gs, '');\n\n // Exclude text inside list items.\n text = text.replace(/<li(?:[^>]+)?>(.*?)<\\/li>/gi, '');\n\n let sentences = getSentences(text, memoizedTokenizer);\n\n let sentenceBeginnings = sentences.map(function(sentence) {\n return getSentenceBeginning(\n sentence,\n firstWordExceptions,\n secondWordExceptions,\n getWordsCustomHelper\n );\n });\n\n sentences = sentences.filter(function(sentence) {\n const stripped = stripSpaces(sentence);\n const words = getWordsCustomHelper ? getWordsCustomHelper(stripped) : getWords(stripped);\n return words.length > 0;\n });\n sentenceBeginnings = filter(sentenceBeginnings);\n\n return compareFirstWords(sentenceBeginnings, sentences);\n}\n"],"mappings":"AAAA,OAAOA,QAAQ;AACf,OAAOC,YAAY;AACnB,OAAOC,WAAW;AA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ACM,OAAO,CAAC,CAAC;EAC1BD,IAAI,GAAGlC,gBAAgB,CAACkC,IAAI,CAAC;EAC7BA,IAAI,GAAGjC,wBAAwB,CAACiC,IAAI,EAAEL,KAAK,CAACO,WAAW,IAAIP,KAAK,CAACO,WAAW,CAACC,UAAU,CAAC;;EAExF;EACAH,IAAI,GAAGA,IAAI,CAACI,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;;EAEpC;EACAJ,IAAI,GAAGA,IAAI,CAACI,OAAO,CAAC,+CAA+C,EAAE,EAAE,CAAC;;EAExE;EACAJ,IAAI,GAAGA,IAAI,CAACI,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC;EAEtD,IAAI/B,SAAS,GAAGd,YAAY,CAACyC,IAAI,EAAED,iBAAiB,CAAC;EAErD,IAAI3B,kBAAkB,GAAGC,SAAS,CAACgC,GAAG,CAAC,UAAStB,QAAQ,EAAE;IACxD,OAAOD,oBAAoB,CACzBC,QAAQ,EACRC,mBAAmB,EACnBC,oBAAoB,EACpBC,oBACF,CAAC;EACH,CAAC,CAAC;EAEFb,SAAS,GAAGA,SAAS,CAACV,MAAM,CAAC,UAASoB,QAAQ,EAAE;IAC9C,MAAMI,QAAQ,GAAG3B,WAAW,CAACuB,QAAQ,CAAC;IACtC,MAAMK,KAAK,GAAGF,oBAAoB,GAAGA,oBAAoB,CAACC,QAAQ,CAAC,GAAG7B,QAAQ,CAAC6B,QAAQ,CAAC;IACxF,OAAOC,KAAK,CAACE,MAAM,GAAG,CAAC;EACzB,CAAC,CAAC;EACFlB,kBAAkB,GAAGT,MAAM,CAACS,kBAAkB,CAAC;EAE/C,OAAOD,iBAAiB,CAACC,kBAAkB,EAAEC,SAAS,CAAC;AACzD","ignoreList":[]}
|
|
@@ -15,16 +15,17 @@ import { filterShortcodesFromHTML } from "../helpers";
|
|
|
15
15
|
*
|
|
16
16
|
* @param {Paper} paper The Paper object.
|
|
17
17
|
*
|
|
18
|
+
* @param value
|
|
18
19
|
* @returns {WordCountResult} The number of words found in the text, plus "word" as the unit used in calculating the text length.
|
|
19
20
|
*/
|
|
20
|
-
export default function (paper) {
|
|
21
|
-
let text = paper.getText();
|
|
21
|
+
export default function (paper, value = null) {
|
|
22
|
+
let text = typeof value === 'string' ? value : paper.getText();
|
|
22
23
|
text = removeHtmlBlocks(text);
|
|
23
|
-
text = filterShortcodesFromHTML(text, paper
|
|
24
|
+
text = filterShortcodesFromHTML(text, paper?._attributes && paper._attributes.shortcodes);
|
|
24
25
|
return {
|
|
25
26
|
text: text,
|
|
26
27
|
count: wordCount(text),
|
|
27
|
-
unit:
|
|
28
|
+
unit: 'word'
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
//# sourceMappingURL=wordCountInText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wordCountInText.js","names":["wordCount","removeHtmlBlocks","filterShortcodesFromHTML","paper","text","getText","_attributes","shortcodes","count","unit"],"sources":["../../../src/languageProcessing/researches/wordCountInText.js"],"sourcesContent":["import wordCount from
|
|
1
|
+
{"version":3,"file":"wordCountInText.js","names":["wordCount","removeHtmlBlocks","filterShortcodesFromHTML","paper","value","text","getText","_attributes","shortcodes","count","unit"],"sources":["../../../src/languageProcessing/researches/wordCountInText.js"],"sourcesContent":["import wordCount from '../helpers/word/countWords.js';\nimport removeHtmlBlocks from '../helpers/html/htmlParser';\nimport {filterShortcodesFromHTML} from '../helpers';\n\n/**\n * A result of the word count calculation.\n *\n * @typedef WordCountResult\n * @param {number} count The number of words found in the text.\n * @param {\"word\"} unit The unit used in the text length calculations, always \"word\".\n */\n\n/**\n * Count the words in the text.\n *\n * @param {Paper} paper The Paper object.\n *\n * @param value\n * @returns {WordCountResult} The number of words found in the text, plus \"word\" as the unit used in calculating the text length.\n */\nexport default function(paper, value = null) {\n let text = typeof value === 'string' ? value : paper.getText();\n text = removeHtmlBlocks(text);\n text = filterShortcodesFromHTML(text, paper?._attributes && paper._attributes.shortcodes);\n return {\n text: text,\n count: wordCount(text),\n unit: 'word'\n };\n}\n"],"mappings":"AAAA,OAAOA,SAAS;AAChB,OAAOC,gBAAgB;AACvB,SAAQC,wBAAwB;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,UAASC,KAAK,EAAEC,KAAK,GAAG,IAAI,EAAE;EAC3C,IAAIC,IAAI,GAAG,OAAOD,KAAK,KAAK,QAAQ,GAAGA,KAAK,GAAGD,KAAK,CAACG,OAAO,CAAC,CAAC;EAC9DD,IAAI,GAAGJ,gBAAgB,CAACI,IAAI,CAAC;EAC7BA,IAAI,GAAGH,wBAAwB,CAACG,IAAI,EAAEF,KAAK,EAAEI,WAAW,IAAIJ,KAAK,CAACI,WAAW,CAACC,UAAU,CAAC;EACzF,OAAO;IACLH,IAAI,EAAEA,IAAI;IACVI,KAAK,EAAET,SAAS,CAACK,IAAI,CAAC;IACtBK,IAAI,EAAE;EACR,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { merge } from 'lodash';
|
|
2
2
|
import Assessment from "../assessment";
|
|
3
3
|
import AssessmentResult from "../../../values/AssessmentResult";
|
|
4
|
-
import
|
|
4
|
+
import wordCountInText from "../../../languageProcessing/researches/wordCountInText";
|
|
5
5
|
import countCharacters from "../../../languageProcessing/languages/ja/helpers/countCharacters";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -64,7 +64,7 @@ export default class TextLengthAssessment extends Assessment {
|
|
|
64
64
|
* @returns {{score: number, body: React.JSX.Element, status: string}}
|
|
65
65
|
*/
|
|
66
66
|
calculateResult(paper, i18n) {
|
|
67
|
-
const wordCount =
|
|
67
|
+
const wordCount = wordCountInText(paper).count;
|
|
68
68
|
const charCount = countCharacters(paper.getText());
|
|
69
69
|
let status = 'bad';
|
|
70
70
|
if (charCount < 2500 && wordCount >= 600) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextLengthAssessment.js","names":["merge","Assessment","AssessmentResult","
|
|
1
|
+
{"version":3,"file":"TextLengthAssessment.js","names":["merge","Assessment","AssessmentResult","wordCountInText","countCharacters","TextLengthAssessment","constructor","config","defaultConfig","id","ctaType","docUrl","priority","fixPosition","title","content","good","improve","bad","identifier","_config","getResult","paper","researcher","i18n","calculatedResult","calculateResult","assessmentResult","setScore","score","setStatus","status","wordCount","count","charCount","getText","getScore"],"sources":["../../../../src/scoring/assessments/seo/TextLengthAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport wordCountInText from '@axyseo/languageProcessing/researches/wordCountInText';\nimport countCharacters from '@axyseo/languageProcessing/languages/ja/helpers/countCharacters';\n\n/**\n * Represents an assessment that checks the length of the text and gives feedback accordingly.\n */\nexport default class TextLengthAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {Object} [config] The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'textLength',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#text-length',\n priority: 'high',\n fixPosition: 'description',\n title: 'Text length',\n content: {\n good: 'Text length is optimized.',\n improve:\n 'Content length is acceptable, but could be expanded to 2,500 characters for more value.',\n bad:\n 'Insufficient content. Aim for at least 600 words to provide value and rank well in search results.'\n }\n };\n\n this.identifier = 'textLength';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Executes the Assessment and returns a result.\n *\n * @param {Paper} paper The Paper object to assess.\n * @param {Researcher} researcher The Researcher object containing all available researches.\n *\n * @param i18n\n * @returns {AssessmentResult} The result of the assessment, containing both a score and a descriptive text.\n */\n getResult({paper, researcher, i18n}) {\n const calculatedResult = this.calculateResult(paper, i18n);\n\n const assessmentResult = new AssessmentResult({config: this._config});\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n\n return assessmentResult;\n }\n\n /**\n *\n * @param paper\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(paper, i18n) {\n const wordCount = wordCountInText(paper).count;\n const charCount = countCharacters(paper.getText());\n\n let status = 'bad';\n if (charCount < 2500 && wordCount >= 600) {\n status = 'improve';\n }\n if (wordCount < 600 && charCount < 2500) {\n status = 'bad';\n }\n if (charCount >= 2500 && wordCount >= 600) {\n status = 'good';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status\n };\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AACvB,OAAOC,eAAe;AACtB,OAAOC,eAAe;;AAEtB;AACA;AACA;AACA,eAAe,MAAMC,oBAAoB,SAASJ,UAAU,CAAC;EAC3D;AACF;AACA;AACA;AACA;AACA;AACA;EACEK,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,YAAY;MAChBC,OAAO,EAAE,KAAK;MACdC,MAAM,EACJ,yFAAyF;MAC3FC,QAAQ,EAAE,MAAM;MAChBC,WAAW,EAAE,aAAa;MAC1BC,KAAK,EAAE,aAAa;MACpBC,OAAO,EAAE;QACPC,IAAI,EAAE,2BAA2B;QACjCC,OAAO,EACL,yFAAyF;QAC3FC,GAAG,EACD;MACJ;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAG,YAAY;IAC9B,IAAI,CAACC,OAAO,GAAGpB,KAAK,CAACQ,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEc,SAASA,CAAC;IAACC,KAAK;IAAEC,UAAU;IAAEC;EAAI,CAAC,EAAE;IACnC,MAAMC,gBAAgB,GAAG,IAAI,CAACC,eAAe,CAACJ,KAAK,EAAEE,IAAI,C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