axyseo 2.0.0-alpha.0.0.57 → 2.0.0-alpha.0.0.59

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.
Files changed (55) hide show
  1. package/build/const/analysis.js +28 -2
  2. package/build/const/analysis.js.map +1 -1
  3. package/build/languageProcessing/researches/getSentenceBeginnings.js +0 -3
  4. package/build/languageProcessing/researches/getSentenceBeginnings.js.map +1 -1
  5. package/build/scoring/assessments/readability/ParagraphTooLongAssessment.js +3 -3
  6. package/build/scoring/assessments/readability/ParagraphTooLongAssessment.js.map +1 -1
  7. package/build/scoring/assessments/readability/RelatedKeywordsAssessment.js +3 -2
  8. package/build/scoring/assessments/readability/RelatedKeywordsAssessment.js.map +1 -1
  9. package/build/scoring/assessments/readability/SentenceBeginningsAssessment.js +3 -2
  10. package/build/scoring/assessments/readability/SentenceBeginningsAssessment.js.map +1 -1
  11. package/build/scoring/assessments/readability/SentenceLengthInTextAssessment.js +3 -2
  12. package/build/scoring/assessments/readability/SentenceLengthInTextAssessment.js.map +1 -1
  13. package/build/scoring/assessments/readability/TransitionWordsAssessment.js +3 -2
  14. package/build/scoring/assessments/readability/TransitionWordsAssessment.js.map +1 -1
  15. package/build/scoring/assessments/seo/ImageCountAssessment.js +3 -2
  16. package/build/scoring/assessments/seo/ImageCountAssessment.js.map +1 -1
  17. package/build/scoring/assessments/seo/InternalLinksAssessment.js +3 -2
  18. package/build/scoring/assessments/seo/InternalLinksAssessment.js.map +1 -1
  19. package/build/scoring/assessments/seo/IntroductionKeywordAssessment.js +3 -2
  20. package/build/scoring/assessments/seo/IntroductionKeywordAssessment.js.map +1 -1
  21. package/build/scoring/assessments/seo/KeyphraseAssessment.js +3 -2
  22. package/build/scoring/assessments/seo/KeyphraseAssessment.js.map +1 -1
  23. package/build/scoring/assessments/seo/KeyphraseLengthAssessment.js +3 -2
  24. package/build/scoring/assessments/seo/KeyphraseLengthAssessment.js.map +1 -1
  25. package/build/scoring/assessments/seo/KeywordDensityAssessment.js +3 -2
  26. package/build/scoring/assessments/seo/KeywordDensityAssessment.js.map +1 -1
  27. package/build/scoring/assessments/seo/MetaDescriptionKeywordAssessment.js +3 -2
  28. package/build/scoring/assessments/seo/MetaDescriptionKeywordAssessment.js.map +1 -1
  29. package/build/scoring/assessments/seo/MetaDescriptionLengthAssessment.js +3 -2
  30. package/build/scoring/assessments/seo/MetaDescriptionLengthAssessment.js.map +1 -1
  31. package/build/scoring/assessments/seo/MetaTitleKeywordAssessment.js +3 -2
  32. package/build/scoring/assessments/seo/MetaTitleKeywordAssessment.js.map +1 -1
  33. package/build/scoring/assessments/seo/NumberInMetaTitleAssessment.js +3 -2
  34. package/build/scoring/assessments/seo/NumberInMetaTitleAssessment.js.map +1 -1
  35. package/build/scoring/assessments/seo/OutboundLinksAssessment.js +3 -2
  36. package/build/scoring/assessments/seo/OutboundLinksAssessment.js.map +1 -1
  37. package/build/scoring/assessments/seo/PageTitleWidthAssessment.js +3 -2
  38. package/build/scoring/assessments/seo/PageTitleWidthAssessment.js.map +1 -1
  39. package/build/scoring/assessments/seo/SchemaAssessment.js +3 -2
  40. package/build/scoring/assessments/seo/SchemaAssessment.js.map +1 -1
  41. package/build/scoring/assessments/seo/SingleH1Assessment.js +3 -2
  42. package/build/scoring/assessments/seo/SingleH1Assessment.js.map +1 -1
  43. package/build/scoring/assessments/seo/SingleTitleAssessment.js +3 -2
  44. package/build/scoring/assessments/seo/SingleTitleAssessment.js.map +1 -1
  45. package/build/scoring/assessments/seo/SubHeadingsKeywordAssessment.js +3 -2
  46. package/build/scoring/assessments/seo/SubHeadingsKeywordAssessment.js.map +1 -1
  47. package/build/scoring/assessments/seo/TextImagesAssessment.js +3 -2
  48. package/build/scoring/assessments/seo/TextImagesAssessment.js.map +1 -1
  49. package/build/scoring/assessments/seo/TextLengthAssessment.js +3 -2
  50. package/build/scoring/assessments/seo/TextLengthAssessment.js.map +1 -1
  51. package/build/scoring/assessments/seo/UrlKeywordAssessment.js +3 -2
  52. package/build/scoring/assessments/seo/UrlKeywordAssessment.js.map +1 -1
  53. package/build/scoring/assessments/seo/UrlLengthAssessment.js +3 -2
  54. package/build/scoring/assessments/seo/UrlLengthAssessment.js.map +1 -1
  55. package/package.json +1 -1
@@ -9,6 +9,32 @@ export const statusRate = {
9
9
  improve: 0.5,
10
10
  bad: 0
11
11
  };
12
- export const technicalSEOCategory = ['singleH1', 'metaDescriptionLength', 'urlLength', 'internalLinks', 'externalLinks', 'titleWidth', 'textImages', 'schema', 'singleTitle'];
13
- export const contentSEOCategory = ['introductionKeyword', 'sentenceBeginnings', 'textSentenceLength', 'textLength', 'titleKeyword', 'keyphraseLength', 'textTransitionWords', 'keyphraseDensity', 'slugKeyword', 'keyphrase', 'textParagraphTooLong', 'subheadingsKeyword', 'images', 'numberTitle', 'metaDescriptionKeyword', 'relatedKeywords'];
12
+ export const SINGLE_H1_ID = 'singleH1';
13
+ export const META_DESCRIPTION_LENGTH_ID = 'metaDescriptionLength';
14
+ export const URL_LENGTH_ID = 'urlLength';
15
+ export const INTERNAL_LINKS_ID = 'internalLinks';
16
+ export const EXTERNAL_LINKS_ID = 'externalLinks';
17
+ export const TITLE_WIDTH_ID = 'titleWidth';
18
+ export const TEXT_IMAGES_ID = 'textImages';
19
+ export const SCHEMA_ID = 'schema';
20
+ export const SINGLE_TITLE_ID = 'singleTitle';
21
+ export const technicalSEOCategory = [SINGLE_H1_ID, META_DESCRIPTION_LENGTH_ID, URL_LENGTH_ID, INTERNAL_LINKS_ID, EXTERNAL_LINKS_ID, TITLE_WIDTH_ID, TEXT_IMAGES_ID, SCHEMA_ID, SINGLE_TITLE_ID];
22
+ export const INTRODUCTION_KEYWORD_ID = 'introductionKeyword';
23
+ export const SENTENCE_BEGGININGS_ID = 'sentenceBeginnings';
24
+ export const TEXT_SENTENCE_LENGTH_ID = 'textSentenceLength';
25
+ export const TEXT_LENGTH_ID = 'textLength';
26
+ export const TITLE_KEYWORD_ID = 'titleKeyword';
27
+ export const KEYPHRASE_LENGTH_ID = 'keyphraseLength';
28
+ export const TEXT_TRANSITION_WORDS_ID = 'textTransitionWords';
29
+ export const KEYPHRASE_DENSITY_ID = 'keyphraseDensity';
30
+ export const SLUG_KEYWORD_ID = 'slugKeyword';
31
+ export const KEYPHRASE_ID = 'keyphrase';
32
+ export const TEXT_PARAGRAPH_TOO_LONG_ID = 'textParagraphTooLong';
33
+ export const SUBHEADINGS_KEYWORD_ID = 'subheadingsKeyword';
34
+ export const IMAGES_ID = 'images';
35
+ export const NUMBER_TITLE_ID = 'numberTitle';
36
+ export const META_DESCRIPTION_KEYWORD_ID = 'metaDescriptionKeyword';
37
+ export const RELATED_KEYWORDS_ID = 'relatedKeywords';
38
+ export const MEDIA_ID = 'media';
39
+ export const contentSEOCategory = [INTRODUCTION_KEYWORD_ID, SENTENCE_BEGGININGS_ID, TEXT_SENTENCE_LENGTH_ID, TEXT_LENGTH_ID, TITLE_KEYWORD_ID, KEYPHRASE_LENGTH_ID, TEXT_TRANSITION_WORDS_ID, KEYPHRASE_DENSITY_ID, SLUG_KEYWORD_ID, KEYPHRASE_ID, TEXT_PARAGRAPH_TOO_LONG_ID, SUBHEADINGS_KEYWORD_ID, IMAGES_ID, NUMBER_TITLE_ID, META_DESCRIPTION_KEYWORD_ID, RELATED_KEYWORDS_ID, MEDIA_ID];
14
40
  //# sourceMappingURL=analysis.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"analysis.js","names":["POINT","priorityRate","high","medium","low","statusRate","good","improve","bad","technicalSEOCategory","contentSEOCategory"],"sources":["../../src/const/analysis.js"],"sourcesContent":["export const POINT = 100;\nexport const priorityRate = {\n high: 1,\n medium: 0.75,\n low: 0.5\n};\nexport const statusRate = {\n good: 1,\n improve: 0.5,\n bad: 0\n};\n\nexport const technicalSEOCategory = [\n 'singleH1',\n 'metaDescriptionLength',\n 'urlLength',\n 'internalLinks',\n 'externalLinks',\n 'titleWidth',\n 'textImages',\n 'schema',\n 'singleTitle'\n];\n\nexport const contentSEOCategory = [\n 'introductionKeyword',\n 'sentenceBeginnings',\n 'textSentenceLength',\n 'textLength',\n 'titleKeyword',\n 'keyphraseLength',\n 'textTransitionWords',\n 'keyphraseDensity',\n 'slugKeyword',\n 'keyphrase',\n 'textParagraphTooLong',\n 'subheadingsKeyword',\n 'images',\n 'numberTitle',\n 'metaDescriptionKeyword',\n 'relatedKeywords'\n];\n"],"mappings":"AAAA,OAAO,MAAMA,KAAK,GAAG,GAAG;AACxB,OAAO,MAAMC,YAAY,GAAG;EAC1BC,IAAI,EAAE,CAAC;EACPC,MAAM,EAAE,IAAI;EACZC,GAAG,EAAE;AACP,CAAC;AACD,OAAO,MAAMC,UAAU,GAAG;EACxBC,IAAI,EAAE,CAAC;EACPC,OAAO,EAAE,GAAG;EACZC,GAAG,EAAE;AACP,CAAC;AAED,OAAO,MAAMC,oBAAoB,GAAG,CAClC,UAAU,EACV,uBAAuB,EACvB,WAAW,EACX,eAAe,EACf,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,aAAa,CACd;AAED,OAAO,MAAMC,kBAAkB,GAAG,CAChC,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,QAAQ,EACR,aAAa,EACb,wBAAwB,EACxB,iBAAiB,CAClB","ignoreList":[]}
1
+ {"version":3,"file":"analysis.js","names":["POINT","priorityRate","high","medium","low","statusRate","good","improve","bad","SINGLE_H1_ID","META_DESCRIPTION_LENGTH_ID","URL_LENGTH_ID","INTERNAL_LINKS_ID","EXTERNAL_LINKS_ID","TITLE_WIDTH_ID","TEXT_IMAGES_ID","SCHEMA_ID","SINGLE_TITLE_ID","technicalSEOCategory","INTRODUCTION_KEYWORD_ID","SENTENCE_BEGGININGS_ID","TEXT_SENTENCE_LENGTH_ID","TEXT_LENGTH_ID","TITLE_KEYWORD_ID","KEYPHRASE_LENGTH_ID","TEXT_TRANSITION_WORDS_ID","KEYPHRASE_DENSITY_ID","SLUG_KEYWORD_ID","KEYPHRASE_ID","TEXT_PARAGRAPH_TOO_LONG_ID","SUBHEADINGS_KEYWORD_ID","IMAGES_ID","NUMBER_TITLE_ID","META_DESCRIPTION_KEYWORD_ID","RELATED_KEYWORDS_ID","MEDIA_ID","contentSEOCategory"],"sources":["../../src/const/analysis.js"],"sourcesContent":["export const POINT = 100;\nexport const priorityRate = {\n high: 1,\n medium: 0.75,\n low: 0.5\n};\nexport const statusRate = {\n good: 1,\n improve: 0.5,\n bad: 0\n};\nexport const SINGLE_H1_ID = 'singleH1';\nexport const META_DESCRIPTION_LENGTH_ID = 'metaDescriptionLength';\nexport const URL_LENGTH_ID = 'urlLength';\nexport const INTERNAL_LINKS_ID = 'internalLinks';\nexport const EXTERNAL_LINKS_ID = 'externalLinks';\nexport const TITLE_WIDTH_ID = 'titleWidth';\nexport const TEXT_IMAGES_ID = 'textImages';\nexport const SCHEMA_ID = 'schema';\nexport const SINGLE_TITLE_ID = 'singleTitle';\n\nexport const technicalSEOCategory = [\n SINGLE_H1_ID,\n META_DESCRIPTION_LENGTH_ID,\n URL_LENGTH_ID,\n INTERNAL_LINKS_ID,\n EXTERNAL_LINKS_ID,\n TITLE_WIDTH_ID,\n TEXT_IMAGES_ID,\n SCHEMA_ID,\n SINGLE_TITLE_ID\n];\n\nexport const INTRODUCTION_KEYWORD_ID = 'introductionKeyword';\nexport const SENTENCE_BEGGININGS_ID = 'sentenceBeginnings';\nexport const TEXT_SENTENCE_LENGTH_ID = 'textSentenceLength';\nexport const TEXT_LENGTH_ID = 'textLength';\nexport const TITLE_KEYWORD_ID = 'titleKeyword';\nexport const KEYPHRASE_LENGTH_ID = 'keyphraseLength';\nexport const TEXT_TRANSITION_WORDS_ID = 'textTransitionWords';\nexport const KEYPHRASE_DENSITY_ID = 'keyphraseDensity';\nexport const SLUG_KEYWORD_ID = 'slugKeyword';\nexport const KEYPHRASE_ID = 'keyphrase';\nexport const TEXT_PARAGRAPH_TOO_LONG_ID = 'textParagraphTooLong';\nexport const SUBHEADINGS_KEYWORD_ID = 'subheadingsKeyword';\nexport const IMAGES_ID = 'images';\nexport const NUMBER_TITLE_ID = 'numberTitle';\nexport const META_DESCRIPTION_KEYWORD_ID = 'metaDescriptionKeyword';\nexport const RELATED_KEYWORDS_ID = 'relatedKeywords';\nexport const MEDIA_ID = 'media';\n\nexport const contentSEOCategory = [\n INTRODUCTION_KEYWORD_ID,\n SENTENCE_BEGGININGS_ID,\n TEXT_SENTENCE_LENGTH_ID,\n TEXT_LENGTH_ID,\n TITLE_KEYWORD_ID,\n KEYPHRASE_LENGTH_ID,\n TEXT_TRANSITION_WORDS_ID,\n KEYPHRASE_DENSITY_ID,\n SLUG_KEYWORD_ID,\n KEYPHRASE_ID,\n TEXT_PARAGRAPH_TOO_LONG_ID,\n SUBHEADINGS_KEYWORD_ID,\n IMAGES_ID,\n NUMBER_TITLE_ID,\n META_DESCRIPTION_KEYWORD_ID,\n RELATED_KEYWORDS_ID,\n MEDIA_ID\n];\n"],"mappings":"AAAA,OAAO,MAAMA,KAAK,GAAG,GAAG;AACxB,OAAO,MAAMC,YAAY,GAAG;EAC1BC,IAAI,EAAE,CAAC;EACPC,MAAM,EAAE,IAAI;EACZC,GAAG,EAAE;AACP,CAAC;AACD,OAAO,MAAMC,UAAU,GAAG;EACxBC,IAAI,EAAE,CAAC;EACPC,OAAO,EAAE,GAAG;EACZC,GAAG,EAAE;AACP,CAAC;AACD,OAAO,MAAMC,YAAY,GAAG,UAAU;AACtC,OAAO,MAAMC,0BAA0B,GAAG,uBAAuB;AACjE,OAAO,MAAMC,aAAa,GAAG,WAAW;AACxC,OAAO,MAAMC,iBAAiB,GAAG,eAAe;AAChD,OAAO,MAAMC,iBAAiB,GAAG,eAAe;AAChD,OAAO,MAAMC,cAAc,GAAG,YAAY;AAC1C,OAAO,MAAMC,cAA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,CACT","ignoreList":[]}
@@ -99,9 +99,6 @@ export default function (paper, researcher) {
99
99
 
100
100
  // Exclude text inside tables.
101
101
  text = text.replace(/<figure class='wp-block-table'>.*<\/figure>/gs, '');
102
-
103
- // Exclude text inside list items.
104
- text = text.replace(/<li(?:[^>]+)?>(.*?)<\/li>/gi, '');
105
102
  let sentences = getSentences(text, memoizedTokenizer);
106
103
  let sentenceBeginnings = sentences.map(function (sentence) {
107
104
  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","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;AAClB,SAAQC,aAAa,IAAIC,SAAS;AAElC,SAAQC,MAAM,EAAEC,OAAO,EAAEC,OAAO,QAAO,QAAQ;AAC/C,OAAOC,gBAAgB;AACvB,SAAQC,wBAAwB;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG,SAAAA,CAASC,wBAAwB,EAAEC,qBAAqB,EAAE;EACnF,OAAO,CAACL,OAAO,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pC;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":[]}
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 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;AAClB,SAAQC,aAAa,IAAIC,SAAS;AAElC,SAAQC,MAAM,EAAEC,OAAO,EAAEC,OAAO,QAAO,QAAQ;AAC/C,OAAOC,gBAAgB;AACvB,SAAQC,wBAAwB;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG,SAAAA,CAASC,wBAAwB,EAAEC,qBAAqB,EAAE;EACnF,OAAO,CAACL,OAAO,CAACI,wBAAwB,CAAC,IAAIA,wBAAwB,KAAKC,qBAAqB;AACjG,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG,SAAAA,CAASC,kBAAkB,EAAEC,SAAS,EAAE;EAChE,MAAMC,qBAAqB,GAAG,EAAE;EAChC,IAAIC,cAAc,GAAG,EAAE;EACvB,IAAIC,cAAc,GAAG,CAAC;EAEtBZ,OAAO,CAACQ,kBAAkB,EAAE,UAASK,SAAS,EAAEC,CAAC,EAAE;IACjD,MAAMT,wBAAwB,GAAGQ,SAAS;IAC1C,MAAMP,qBAAqB,GAAGE,kBAAkB,CAACM,CAAC,GAAG,CAAC,CAAC;IACvDH,cAAc,CAACI,IAAI,CAACN,SAAS,CAACK,CAAC,CAAC,CAAC;IAEjC,IAAIV,kBAAkB,CAACC,wBAAwB,EAAEC,qBAAqB,CAAC,EAAE;MACvEM,cAAc,EAAE;IAClB,CAAC,MAAM;MACLF,qBAAqB,CAACK,IAAI,CAAC;QACzBC,IAAI,EAAEX,wBAAwB;QAC9BY,KAAK,EAAEL,cAAc;QACrBH,SAAS,EAAEE;MACb,CAAC,CAAC;MACFC,cAAc,GAAG,CAAC;MAClBD,cAAc,GAAG,EAAE;IACrB;EACF,CAAC,CAAC;EAEF,OAAOD,qBAAqB;AAC9B,CAAC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CAACE,SAAS,CAAC,sBAAsB,CAAC;EACzE,MAAMC,iBAAiB,GAAGH,UAAU,CAACE,SAAS,CAAC,mBAAmB,CAAC;EAEnE,IAAIE,IAAI,GAAGL,KAAK,CAACM,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,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":[]}
@@ -1,8 +1,8 @@
1
1
  import { merge } from 'lodash';
2
- ;
3
2
  import { inRangeEndInclusive as inRange } from "../../helpers/assessments/inRange";
4
3
  import AssessmentResult from "../../../values/AssessmentResult";
5
4
  import Assessment from "../assessment";
5
+ import { TEXT_PARAGRAPH_TOO_LONG_ID } from "../../../const/analysis";
6
6
 
7
7
  /**
8
8
  * Represents the assessment that will look if the text has too long paragraphs.
@@ -18,7 +18,7 @@ export default class ParagraphTooLongAssessment extends Assessment {
18
18
  constructor(config = {}) {
19
19
  super();
20
20
  const defaultConfig = {
21
- id: 'textParagraphTooLong',
21
+ id: TEXT_PARAGRAPH_TOO_LONG_ID,
22
22
  priority: 'high',
23
23
  docUrl: 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#paragraph-length',
24
24
  fixPosition: 'longParagraph',
@@ -34,7 +34,7 @@ export default class ParagraphTooLongAssessment extends Assessment {
34
34
  good: 'Paragraph is optimized, with less than 150 words.'
35
35
  }
36
36
  };
37
- this.identifier = 'textParagraphTooLong';
37
+ this.identifier = TEXT_PARAGRAPH_TOO_LONG_ID;
38
38
  this._config = merge(defaultConfig, config);
39
39
  }
40
40
 
@@ -1 +1 @@
1
- {"version":3,"file":"ParagraphTooLongAssessment.js","names":["merge","inRangeEndInclusive","inRange","AssessmentResult","Assessment","ParagraphTooLongAssessment","constructor","config","defaultConfig","id","priority","docUrl","fixPosition","ctaType","parameters","recommendedLength","maximumRecommendedLength","title","content","bad","improve","good","identifier","_config","getConfig","researcher","currentConfig","languageSpecificConfig","_isProduct","productPageParams","defaultPageParams","calculateResult","paragraphsLength","i18n","status","length","longestParagraphLength","countLength","score","getScore","sortParagraphs","paragraphs","sort","a","b","getResult","paper","getResearch","paragraphLengthResult","assessmentResult","setScore","setStatus","setBody","body","isApplicable","hasEnoughContentForAssessment"],"sources":["../../../../src/scoring/assessments/readability/ParagraphTooLongAssessment.js"],"sourcesContent":["import {merge} from 'lodash';;\nimport {inRangeEndInclusive as inRange} from '../../helpers/assessments/inRange';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\n\n/**\n * Represents the assessment that will look if the text has too long paragraphs.\n */\nexport default class ParagraphTooLongAssessment 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: 'textParagraphTooLong',\n priority: 'high',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#paragraph-length',\n fixPosition: 'longParagraph',\n ctaType: 'fix',\n parameters: {\n recommendedLength: 150,\n maximumRecommendedLength: 150\n },\n title: 'Paragraph length',\n content: {\n bad: 'Paragraph too long. Keep paragraph length less than 150 words for readability.',\n improve: '',\n good: 'Paragraph is optimized, with less than 150 words.'\n }\n };\n\n this.identifier = 'textParagraphTooLong';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Check if there is language-specific config, and if so, overwrite the current config with it.\n *\n * @param {Researcher} researcher The researcher to use.\n *\n * @returns {Object} The config that should be used.\n */\n getConfig(researcher) {\n const currentConfig = this._config;\n const languageSpecificConfig = researcher.getConfig('paragraphLength');\n\n /*\n * If a language has a specific paragraph length config, check further if the assessment is run in product pages.\n * If it's run in product pages, override the default config parameters with the language specific config for product pages,\n * otherwise override it with the language specific config for default pages analysis.\n */\n if (languageSpecificConfig) {\n currentConfig.parameters = this._isProduct\n ? languageSpecificConfig.productPageParams\n : languageSpecificConfig.defaultPageParams;\n }\n\n return currentConfig;\n }\n\n /**\n *\n * @param paragraphsLength\n * @param tooLongParagraphs\n * @param config\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult({paragraphsLength, config, i18n}) {\n let status = 'bad';\n if (paragraphsLength.length === 0) {\n status = 'good';\n } else {\n const longestParagraphLength = paragraphsLength[0].countLength;\n\n if (longestParagraphLength <= config.parameters.recommendedLength) {\n status = 'good';\n }\n\n if (\n inRange(\n longestParagraphLength,\n config.parameters.recommendedLength,\n config.parameters.maximumRecommendedLength\n )\n ) {\n status = 'good';\n }\n\n if (longestParagraphLength > config.parameters.maximumRecommendedLength) {\n status = 'bad';\n }\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status\n };\n }\n\n /**\n * Sort the paragraphs based on word count.\n *\n * @param {Array} paragraphs The array with paragraphs.\n *\n * @returns {Array} The array sorted on word counts.\n */\n sortParagraphs(paragraphs) {\n return paragraphs.sort(function(a, b) {\n return b.countLength - a.countLength;\n });\n }\n\n /**\n * Runs the getParagraphLength module, based on this returns an assessment result with score and text.\n *\n * @param {Paper} paper The paper to use for the assessment.\n * @param {Researcher} researcher The researcher used for calling research.\n * @param i18n\n * @returns {object} The assessment result.\n */\n getResult({paper, researcher, i18n}) {\n let paragraphsLength = researcher.getResearch('getParagraphLength');\n\n paragraphsLength = this.sortParagraphs(paragraphsLength);\n const config = this.getConfig(researcher);\n\n const paragraphLengthResult = this.calculateResult({\n paragraphsLength,\n config,\n i18n\n });\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(paragraphLengthResult.score);\n assessmentResult.setStatus(paragraphLengthResult.status);\n assessmentResult.setBody(paragraphLengthResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the paragraphTooLong assessment is applicable to the paper.\n *\n * @param {Paper} paper The paper to check.\n *\n * @returns {boolean} Returns true if the assessment is applicable to the paper.\n */\n isApplicable(paper) {\n return this.hasEnoughContentForAssessment(paper);\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAAC;AAC7B,SAAQC,mBAAmB,IAAIC,OAAO;AACtC,OAAOC,gBAAgB;AACvB,OAAOC,UAAU;;AAEjB;AACA;AACA;AACA,eAAe,MAAMC,0BAA0B,SAASD,UAAU,CAAC;EACjE;AACF;AACA;AACA;AACA;AACA;AACA;EACEE,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,sBAAsB;MAC1BC,QAAQ,EAAE,MAAM;MAChBC,MAAM,EAC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G,OAAO,CAACJ,qBAAqB,CAACK,IAAI,CAAC;IAEpD,OAAOJ,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEK,YAAYA,CAACR,KAAK,EAAE;IAClB,OAAO,IAAI,CAACS,6BAA6B,CAACT,KAAK,CAAC;EAClD;AACF","ignoreList":[]}
1
+ {"version":3,"file":"ParagraphTooLongAssessment.js","names":["merge","inRangeEndInclusive","inRange","AssessmentResult","Assessment","TEXT_PARAGRAPH_TOO_LONG_ID","ParagraphTooLongAssessment","constructor","config","defaultConfig","id","priority","docUrl","fixPosition","ctaType","parameters","recommendedLength","maximumRecommendedLength","title","content","bad","improve","good","identifier","_config","getConfig","researcher","currentConfig","languageSpecificConfig","_isProduct","productPageParams","defaultPageParams","calculateResult","paragraphsLength","i18n","status","length","longestParagraphLength","countLength","score","getScore","sortParagraphs","paragraphs","sort","a","b","getResult","paper","getResearch","paragraphLengthResult","assessmentResult","setScore","setStatus","setBody","body","isApplicable","hasEnoughContentForAssessment"],"sources":["../../../../src/scoring/assessments/readability/ParagraphTooLongAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport {inRangeEndInclusive as inRange} from '../../helpers/assessments/inRange';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\nimport {TEXT_PARAGRAPH_TOO_LONG_ID} from '@axyseo/const/analysis';\n\n/**\n * Represents the assessment that will look if the text has too long paragraphs.\n */\nexport default class ParagraphTooLongAssessment 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: TEXT_PARAGRAPH_TOO_LONG_ID,\n priority: 'high',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#paragraph-length',\n fixPosition: 'longParagraph',\n ctaType: 'fix',\n parameters: {\n recommendedLength: 150,\n maximumRecommendedLength: 150\n },\n title: 'Paragraph length',\n content: {\n bad: 'Paragraph too long. Keep paragraph length less than 150 words for readability.',\n improve: '',\n good: 'Paragraph is optimized, with less than 150 words.'\n }\n };\n\n this.identifier = TEXT_PARAGRAPH_TOO_LONG_ID;\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Check if there is language-specific config, and if so, overwrite the current config with it.\n *\n * @param {Researcher} researcher The researcher to use.\n *\n * @returns {Object} The config that should be used.\n */\n getConfig(researcher) {\n const currentConfig = this._config;\n const languageSpecificConfig = researcher.getConfig('paragraphLength');\n\n /*\n * If a language has a specific paragraph length config, check further if the assessment is run in product pages.\n * If it's run in product pages, override the default config parameters with the language specific config for product pages,\n * otherwise override it with the language specific config for default pages analysis.\n */\n if (languageSpecificConfig) {\n currentConfig.parameters = this._isProduct\n ? languageSpecificConfig.productPageParams\n : languageSpecificConfig.defaultPageParams;\n }\n\n return currentConfig;\n }\n\n /**\n *\n * @param paragraphsLength\n * @param tooLongParagraphs\n * @param config\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult({paragraphsLength, config, i18n}) {\n let status = 'bad';\n if (paragraphsLength.length === 0) {\n status = 'good';\n } else {\n const longestParagraphLength = paragraphsLength[0].countLength;\n\n if (longestParagraphLength <= config.parameters.recommendedLength) {\n status = 'good';\n }\n\n if (\n inRange(\n longestParagraphLength,\n config.parameters.recommendedLength,\n config.parameters.maximumRecommendedLength\n )\n ) {\n status = 'good';\n }\n\n if (longestParagraphLength > config.parameters.maximumRecommendedLength) {\n status = 'bad';\n }\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status\n };\n }\n\n /**\n * Sort the paragraphs based on word count.\n *\n * @param {Array} paragraphs The array with paragraphs.\n *\n * @returns {Array} The array sorted on word counts.\n */\n sortParagraphs(paragraphs) {\n return paragraphs.sort(function(a, b) {\n return b.countLength - a.countLength;\n });\n }\n\n /**\n * Runs the getParagraphLength module, based on this returns an assessment result with score and text.\n *\n * @param {Paper} paper The paper to use for the assessment.\n * @param {Researcher} researcher The researcher used for calling research.\n * @param i18n\n * @returns {object} The assessment result.\n */\n getResult({paper, researcher, i18n}) {\n let paragraphsLength = researcher.getResearch('getParagraphLength');\n\n paragraphsLength = this.sortParagraphs(paragraphsLength);\n const config = this.getConfig(researcher);\n\n const paragraphLengthResult = this.calculateResult({\n paragraphsLength,\n config,\n i18n\n });\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(paragraphLengthResult.score);\n assessmentResult.setStatus(paragraphLengthResult.status);\n assessmentResult.setBody(paragraphLengthResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the paragraphTooLong assessment is applicable to the paper.\n *\n * @param {Paper} paper The paper to check.\n *\n * @returns {boolean} Returns true if the assessment is applicable to the paper.\n */\n isApplicable(paper) {\n return this.hasEnoughContentForAssessment(paper);\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,SAAQC,mBAAmB,IAAIC,OAAO;AACtC,OAAOC,gBAAgB;AACvB,OAAOC,UAAU;AACjB,SAAQC,0BAA0B;;AAElC;AACA;AACA;AACA,eAAe,MAAMC,0BAA0B,SAASF,UAAU,CAAC;EACjE;AACF;AACA;AACA;AACA;AACA;AACA;EACEG,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAEL,0BAA0B;MAC9BM,QAAQ,EAAE,MAAM;MAChBC,MAAM,EACJ,8FAA8F;MAChGC,WAAW,EAAE,eAAe;MAC5BC,OAAO,EAAE,KAAK;MACdC,UAAU,EAAE;QACVC,iBAAiB,EAAE,GAAG;QACtBC,wBAAwB,EAAE;MAC5B,CAAC;MACDC,KAAK,EAAE,kBAAkB;MACzBC,OAAO,EAAE;QACPC,GAAG,EAAE,gFAAgF;QACrFC,OAAO,EAAE,EAAE;QACXC,IAAI,EAAE;MACR;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAGlB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AM,CAAC;IAE1D,OAAO;MACLI,KAAK;MACLJ;IACF,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEM,cAAcA,CAACC,UAAU,EAAE;IACzB,OAAOA,UAAU,CAACC,IAAI,CAAC,UAASC,CAAC,EAAEC,CAAC,EAAE;MACpC,OAAOA,CAAC,CAACP,WAAW,GAAGM,CAAC,CAACN,WAAW;IACtC,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEQ,SAASA,CAAC;IAACC,KAAK;IAAErB,UAAU;IAAEQ;EAAI,CAAC,EAAE;IACnC,IAAID,gBAAgB,GAAGP,UAAU,CAACsB,WAAW,CAAC,oBAAoB,CAAC;IAEnEf,gBAAgB,GAAG,IAAI,CAACQ,cAAc,CAACR,gBAAgB,CAAC;IACxD,MAAMzB,MAAM,GAAG,IAAI,CAACiB,SAAS,CAACC,UAAU,CAAC;IAEzC,MAAMuB,qBAAqB,GAAG,IAAI,CAACjB,eAAe,CAAC;MACjDC,gBAAgB;MAChBzB,MAAM;MACN0B;IACF,CAAC,CAAC;IACF,MAAMgB,gBAAgB,GAAG,IAAI/C,gBAAgB,CAAC;MAACK,MAAM,EAAE,IAAI,CAACgB;IAAO,CAAC,CAAC;IAErE0B,gBAAgB,CAACC,QAAQ,CAACF,qBAAqB,CAACV,KAAK,CAAC;IACtDW,gBAAgB,CAACE,SAAS,CAACH,qBAAqB,CAACd,MAAM,CAAC;IACxDe,gBAAgB,CAACG,OAAO,CAACJ,qBAAqB,CAACK,IAAI,CAAC;IAEpD,OAAOJ,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEK,YAAYA,CAACR,KAAK,EAAE;IAClB,OAAO,IAAI,CAACS,6BAA6B,CAACT,KAAK,CAAC;EAClD;AACF","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  import { merge } from 'lodash';
2
2
  import AssessmentResult from "../../../values/AssessmentResult";
3
3
  import Assessment from "../assessment";
4
+ import { RELATED_KEYWORDS_ID } from "../../../const/analysis";
4
5
 
5
6
  /**
6
7
  * Represents the assessment that checks whether there are enough transition words in the text.
@@ -16,7 +17,7 @@ export default class RelatedKeywordsAssessment extends Assessment {
16
17
  constructor(config = {}) {
17
18
  super();
18
19
  const defaultConfig = {
19
- id: 'relatedKeywords',
20
+ id: RELATED_KEYWORDS_ID,
20
21
  fixPosition: 'description',
21
22
  ctaType: 'fix',
22
23
  docUrl: 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#duplicate-title',
@@ -28,7 +29,7 @@ export default class RelatedKeywordsAssessment extends Assessment {
28
29
  improve: 'Too high related keyword density. Keep related keyword density from 0.5% - 1%.'
29
30
  }
30
31
  };
31
- this.identifier = 'relatedKeywords';
32
+ this.identifier = RELATED_KEYWORDS_ID;
32
33
  this._config = merge(defaultConfig, config);
33
34
  }
34
35
 
@@ -1 +1 @@
1
- {"version":3,"file":"RelatedKeywordsAssessment.js","names":["merge","AssessmentResult","Assessment","RelatedKeywordsAssessment","constructor","config","defaultConfig","id","fixPosition","ctaType","docUrl","priority","title","content","good","bad","improve","identifier","_config","calculateResult","data","relatedKeywords","i18n","totalWordUsed","words","isWordUsedExceeding","status","related_keywords","length","score","getScore","getResult","paper","researcher","getResearch","getData","result","assessmentResult","setScore","setStatus","setBody","isApplicable","hasRelatedKeywords"],"sources":["../../../../src/scoring/assessments/readability/RelatedKeywordsAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\n\n/**\n * Represents the assessment that checks whether there are enough transition words in the text.\n */\nexport default class RelatedKeywordsAssessment 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: 'relatedKeywords',\n fixPosition: 'description',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#duplicate-title',\n priority: 'high',\n title: 'Related keywords',\n content: {\n good: 'Related keyword density is optimized',\n bad:\n 'Consider using at least a related keyword in your page to establish topical relevance.',\n improve: 'Too high related keyword density. Keep related keyword density from 0.5% - 1%.'\n }\n };\n\n this.identifier = 'relatedKeywords';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n *\n * @param data\n * @param relatedKeywords\n * @param i18n\n * @returns {{score: number, status: string, words}}\n */\n calculateResult(data, relatedKeywords, i18n) {\n const {totalWordUsed, words, isWordUsedExceeding} = relatedKeywords;\n let status = 'good';\n if (!data?.related_keywords?.length || totalWordUsed <= 0) {\n status = 'bad';\n }\n\n if (isWordUsedExceeding) {\n status = 'improve';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n words\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const relatedKeywords = researcher.getResearch('checkRelatedKeywords');\n const data = paper.getData();\n\n const result = this.calculateResult(data, relatedKeywords, i18n);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(result.score);\n assessmentResult.setStatus(result.status);\n assessmentResult.setBody(result.words);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the transition words assessment is applicable to the paper. Language-specific length requirements and methods of counting text length\n * may apply (e.g. for Japanese, the text should be counted in characters instead of words, which also makes the minimum required length higher).\n *\n * @param {Paper} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available, the paper is not empty and the text is longer than the minimum required length.\n */\n isApplicable(paper, researcher) {\n return paper.hasRelatedKeywords();\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,gBAAgB;AACvB,OAAOC,UAAU;;AAEjB;AACA;AACA;AACA,eAAe,MAAMC,yBAAyB,SAASD,UAAU,CAAC;EAChE;AACF;AACA;AACA;AACA;AACA;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O,CAAC,CAAC;IAE5B,MAAMC,MAAM,GAAG,IAAI,CAACjB,eAAe,CAACC,IAAI,EAAEC,eAAe,EAAEC,IAAI,CAAC;IAChE,MAAMe,gBAAgB,GAAG,IAAIpC,gBAAgB,CAAC;MAACI,MAAM,EAAE,IAAI,CAACa;IAAO,CAAC,CAAC;IAErEmB,gBAAgB,CAACC,QAAQ,CAACF,MAAM,CAACP,KAAK,CAAC;IACvCQ,gBAAgB,CAACE,SAAS,CAACH,MAAM,CAACV,MAAM,CAAC;IACzCW,gBAAgB,CAACG,OAAO,CAACJ,MAAM,CAACZ,KAAK,CAAC;IAEtC,OAAOa,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEI,YAAYA,CAACT,KAAK,EAAEC,UAAU,EAAE;IAC9B,OAAOD,KAAK,CAACU,kBAAkB,CAAC,CAAC;EACnC;AACF","ignoreList":[]}
1
+ {"version":3,"file":"RelatedKeywordsAssessment.js","names":["merge","AssessmentResult","Assessment","RELATED_KEYWORDS_ID","RelatedKeywordsAssessment","constructor","config","defaultConfig","id","fixPosition","ctaType","docUrl","priority","title","content","good","bad","improve","identifier","_config","calculateResult","data","relatedKeywords","i18n","totalWordUsed","words","isWordUsedExceeding","status","related_keywords","length","score","getScore","getResult","paper","researcher","getResearch","getData","result","assessmentResult","setScore","setStatus","setBody","isApplicable","hasRelatedKeywords"],"sources":["../../../../src/scoring/assessments/readability/RelatedKeywordsAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\nimport {RELATED_KEYWORDS_ID} from '@axyseo/const/analysis';\n\n/**\n * Represents the assessment that checks whether there are enough transition words in the text.\n */\nexport default class RelatedKeywordsAssessment 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: RELATED_KEYWORDS_ID,\n fixPosition: 'description',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#duplicate-title',\n priority: 'high',\n title: 'Related keywords',\n content: {\n good: 'Related keyword density is optimized',\n bad:\n 'Consider using at least a related keyword in your page to establish topical relevance.',\n improve: 'Too high related keyword density. Keep related keyword density from 0.5% - 1%.'\n }\n };\n\n this.identifier = RELATED_KEYWORDS_ID;\n this._config = merge(defaultConfig, config);\n }\n\n /**\n *\n * @param data\n * @param relatedKeywords\n * @param i18n\n * @returns {{score: number, status: string, words}}\n */\n calculateResult(data, relatedKeywords, i18n) {\n const {totalWordUsed, words, isWordUsedExceeding} = relatedKeywords;\n let status = 'good';\n if (!data?.related_keywords?.length || totalWordUsed <= 0) {\n status = 'bad';\n }\n\n if (isWordUsedExceeding) {\n status = 'improve';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n words\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const relatedKeywords = researcher.getResearch('checkRelatedKeywords');\n const data = paper.getData();\n\n const result = this.calculateResult(data, relatedKeywords, i18n);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(result.score);\n assessmentResult.setStatus(result.status);\n assessmentResult.setBody(result.words);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the transition words assessment is applicable to the paper. Language-specific length requirements and methods of counting text length\n * may apply (e.g. for Japanese, the text should be counted in characters instead of words, which also makes the minimum required length higher).\n *\n * @param {Paper} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available, the paper is not empty and the text is longer than the minimum required length.\n */\n isApplicable(paper, researcher) {\n return paper.hasRelatedKeywords();\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,gBAAgB;AACvB,OAAOC,UAAU;AACjB,SAAQC,mBAAmB;;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,eAAe,GAAGY,UAAU,CAACC,WAAW,CAAC,sBAAsB,CAAC;IACtE,MAAMd,IAAI,GAAGY,KAAK,CAACG,OAAO,CAAC,CAAC;IAE5B,MAAMC,MAAM,GAAG,IAAI,CAACjB,eAAe,CAACC,IAAI,EAAEC,eAAe,EAAEC,IAAI,CAAC;IAChE,MAAMe,gBAAgB,GAAG,IAAIrC,gBAAgB,CAAC;MAACK,MAAM,EAAE,IAAI,CAACa;IAAO,CAAC,CAAC;IAErEmB,gBAAgB,CAACC,QAAQ,CAACF,MAAM,CAACP,KAAK,CAAC;IACvCQ,gBAAgB,CAACE,SAAS,CAACH,MAAM,CAACV,MAAM,CAAC;IACzCW,gBAAgB,CAACG,OAAO,CAACJ,MAAM,CAACZ,KAAK,CAAC;IAEtC,OAAOa,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEI,YAAYA,CAACT,KAAK,EAAEC,UAAU,EAAE;IAC9B,OAAOD,KAAK,CAACU,kBAAkB,CAAC,CAAC;EACnC;AACF","ignoreList":[]}
@@ -2,6 +2,7 @@ import { merge, partition, sortBy } from 'lodash';
2
2
  import AssessmentResult from "../../../values/AssessmentResult";
3
3
  import Assessment from "../assessment";
4
4
  import { TextBlockIcon } from '@shopify/polaris-icons';
5
+ import { SENTENCE_BEGGININGS_ID } from "../../../const/analysis";
5
6
  const maximumConsecutiveDuplicates = 2;
6
7
 
7
8
  /**
@@ -18,7 +19,7 @@ export default class SentenceBeginningsAssessment extends Assessment {
18
19
  constructor(config = {}) {
19
20
  super();
20
21
  const defaultConfig = {
21
- id: 'sentenceBeginnings',
22
+ id: SENTENCE_BEGGININGS_ID,
22
23
  priority: 'medium',
23
24
  ctaType: 'fix',
24
25
  docUrl: 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#sentence-beginnings',
@@ -31,7 +32,7 @@ export default class SentenceBeginningsAssessment extends Assessment {
31
32
  good: 'No sentences with repetitive beginnings found.'
32
33
  }
33
34
  };
34
- this.identifier = 'sentenceBeginnings';
35
+ this.identifier = SENTENCE_BEGGININGS_ID;
35
36
  this._config = merge(defaultConfig, config);
36
37
  }
37
38
 
@@ -1 +1 @@
1
- {"version":3,"file":"SentenceBeginningsAssessment.js","names":["merge","partition","sortBy","AssessmentResult","Assessment","TextBlockIcon","maximumConsecutiveDuplicates","SentenceBeginningsAssessment","constructor","config","defaultConfig","id","priority","ctaType","docUrl","fixPosition","icon","title","content","improve","bad","good","identifier","_config","groupSentenceBeginnings","sentenceBeginnings","tooOften","word","count","length","total","sortedCounts","lowestCount","calculateSentenceBeginningsResult","groupedSentenceBeginnings","i18n","status","score","getScore","getResult","paper","researcher","getResearch","calculatedResult","assessmentResult","setScore","setStatus","setBody","body","isApplicable","hasEnoughContentForAssessment","hasResearch"],"sources":["../../../../src/scoring/assessments/readability/SentenceBeginningsAssessment.js"],"sourcesContent":["import {merge, partition, sortBy} from 'lodash';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\nimport {TextBlockIcon} from '@shopify/polaris-icons';\n\nconst maximumConsecutiveDuplicates = 2;\n\n/**\n * Represents the assessment that checks whether there are three or more consecutive sentences beginning with the same word.\n */\nexport default class SentenceBeginningsAssessment 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: 'sentenceBeginnings',\n priority: 'medium',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#sentence-beginnings',\n fixPosition: 'description',\n icon: TextBlockIcon,\n title: 'Sentence beginnings',\n content: {\n improve: '',\n bad:\n 'Found sentences with repetitive beginnings. Change the wording for more engaging content.',\n good: 'No sentences with repetitive beginnings found.'\n }\n };\n\n this.identifier = 'sentenceBeginnings';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Counts and groups the number too often used sentence beginnings and determines the lowest count within that group.\n *\n * @param {array} sentenceBeginnings The array containing the objects containing the beginning words and counts.\n *\n * @returns {object} The object containing the total number of too often used beginnings and the lowest count within those.\n */\n groupSentenceBeginnings(sentenceBeginnings) {\n const tooOften = partition(sentenceBeginnings, function(word) {\n return word.count > maximumConsecutiveDuplicates;\n });\n\n if (tooOften[0].length === 0) {\n return {total: 0};\n }\n\n const sortedCounts = sortBy(tooOften[0], function(word) {\n return word.count;\n });\n\n return {total: tooOften[0].length, lowestCount: sortedCounts[0].count};\n }\n\n /**\n *\n * @param groupedSentenceBeginnings\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateSentenceBeginningsResult(groupedSentenceBeginnings, i18n) {\n let status = '';\n if (groupedSentenceBeginnings.total > 0) {\n status = 'bad';\n } else {\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 /**\n *\n * @param paper\n * @param researcher\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const sentenceBeginnings = researcher.getResearch('getSentenceBeginnings');\n const groupedSentenceBeginnings = this.groupSentenceBeginnings(sentenceBeginnings);\n const calculatedResult = this.calculateSentenceBeginningsResult(\n groupedSentenceBeginnings,\n i18n\n );\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the sentence beginnings assessment is applicable to the paper.\n *\n * @param {Object} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available and the paper is not empty.\n */\n isApplicable(paper, researcher) {\n return (\n this.hasEnoughContentForAssessment(paper) && researcher.hasResearch('getSentenceBeginnings')\n );\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,EAAEC,SAAS,EAAEC,MAAM,QAAO,QAAQ;AAC/C,OAAOC,gBAAgB;AACvB,OA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AAU,CAACU,WAAW,CAAC,uBAAuB,CAAC;EAEhG;AACF","ignoreList":[]}
1
+ {"version":3,"file":"SentenceBeginningsAssessment.js","names":["merge","partition","sortBy","AssessmentResult","Assessment","TextBlockIcon","SENTENCE_BEGGININGS_ID","maximumConsecutiveDuplicates","SentenceBeginningsAssessment","constructor","config","defaultConfig","id","priority","ctaType","docUrl","fixPosition","icon","title","content","improve","bad","good","identifier","_config","groupSentenceBeginnings","sentenceBeginnings","tooOften","word","count","length","total","sortedCounts","lowestCount","calculateSentenceBeginningsResult","groupedSentenceBeginnings","i18n","status","score","getScore","getResult","paper","researcher","getResearch","calculatedResult","assessmentResult","setScore","setStatus","setBody","body","isApplicable","hasEnoughContentForAssessment","hasResearch"],"sources":["../../../../src/scoring/assessments/readability/SentenceBeginningsAssessment.js"],"sourcesContent":["import {merge, partition, sortBy} from 'lodash';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\nimport {TextBlockIcon} from '@shopify/polaris-icons';\nimport {SENTENCE_BEGGININGS_ID} from '@axyseo/const/analysis';\n\nconst maximumConsecutiveDuplicates = 2;\n\n/**\n * Represents the assessment that checks whether there are three or more consecutive sentences beginning with the same word.\n */\nexport default class SentenceBeginningsAssessment 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: SENTENCE_BEGGININGS_ID,\n priority: 'medium',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#sentence-beginnings',\n fixPosition: 'description',\n icon: TextBlockIcon,\n title: 'Sentence beginnings',\n content: {\n improve: '',\n bad:\n 'Found sentences with repetitive beginnings. Change the wording for more engaging content.',\n good: 'No sentences with repetitive beginnings found.'\n }\n };\n\n this.identifier = SENTENCE_BEGGININGS_ID;\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Counts and groups the number too often used sentence beginnings and determines the lowest count within that group.\n *\n * @param {array} sentenceBeginnings The array containing the objects containing the beginning words and counts.\n *\n * @returns {object} The object containing the total number of too often used beginnings and the lowest count within those.\n */\n groupSentenceBeginnings(sentenceBeginnings) {\n const tooOften = partition(sentenceBeginnings, function(word) {\n return word.count > maximumConsecutiveDuplicates;\n });\n\n if (tooOften[0].length === 0) {\n return {total: 0};\n }\n\n const sortedCounts = sortBy(tooOften[0], function(word) {\n return word.count;\n });\n\n return {total: tooOften[0].length, lowestCount: sortedCounts[0].count};\n }\n\n /**\n *\n * @param groupedSentenceBeginnings\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateSentenceBeginningsResult(groupedSentenceBeginnings, i18n) {\n let status = '';\n if (groupedSentenceBeginnings.total > 0) {\n status = 'bad';\n } else {\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 /**\n *\n * @param paper\n * @param researcher\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const sentenceBeginnings = researcher.getResearch('getSentenceBeginnings');\n const groupedSentenceBeginnings = this.groupSentenceBeginnings(sentenceBeginnings);\n const calculatedResult = this.calculateSentenceBeginningsResult(\n groupedSentenceBeginnings,\n i18n\n );\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the sentence beginnings assessment is applicable to the paper.\n *\n * @param {Object} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available and the paper is not empty.\n */\n isApplicable(paper, researcher) {\n return (\n this.hasEnoughContentForAssessment(paper) && researcher.hasResearch('getSentenceBeginnings')\n );\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,EAAEC,SAAS,EAAEC,MAAM,QAAO,QAAQ;AAC/C,OAAOC,gBAA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,CAACS,6BAA6B,CAACV,KAAK,CAAC,IAAIC,UAAU,CAACU,WAAW,CAAC,uBAAuB,CAAC;EAEhG;AACF","ignoreList":[]}
@@ -4,6 +4,7 @@ import getTooLongSentences from "../../helpers/assessments/checkForTooLongSenten
4
4
  import formatNumber from "../../../helpers/formatNumber";
5
5
  import AssessmentResult from "../../../values/AssessmentResult";
6
6
  import { TextBlockIcon } from '@shopify/polaris-icons';
7
+ import { TEXT_SENTENCE_LENGTH_ID } from "../../../const/analysis";
7
8
 
8
9
  /**
9
10
  * Represents the assessment that will calculate the length of sentences in the text.
@@ -20,7 +21,7 @@ class SentenceLengthInTextAssessment extends Assessment {
20
21
  constructor(config = {}, isCornerstone = false, isProduct = false) {
21
22
  super();
22
23
  const defaultConfig = {
23
- id: 'textSentenceLength',
24
+ id: TEXT_SENTENCE_LENGTH_ID,
24
25
  priority: 'high',
25
26
  docUrl: 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#sentence-length',
26
27
  ctaType: 'fix',
@@ -37,7 +38,7 @@ class SentenceLengthInTextAssessment extends Assessment {
37
38
  }
38
39
  };
39
40
  this._config = merge(defaultConfig, config);
40
- this.identifier = 'textSentenceLength';
41
+ this.identifier = TEXT_SENTENCE_LENGTH_ID;
41
42
  }
42
43
 
43
44
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"SentenceLengthInTextAssessment.js","names":["merge","Assessment","getTooLongSentences","formatNumber","AssessmentResult","TextBlockIcon","SentenceLengthInTextAssessment","constructor","config","isCornerstone","isProduct","defaultConfig","id","priority","docUrl","ctaType","fixPosition","icon","recommendedLength","slightlyTooMany","farTooMany","title","content","improve","bad","good","_config","identifier","getResult","paper","researcher","i18n","sentences","getResearch","getConfig","getLanguageSpecificConfig","percentage","calculatePercentage","result","calculateResult","assessmentResult","setScore","score","setStatus","status","setBody","body","isApplicable","hasEnoughContentForAssessment","currentConfig","languageSpecificConfig","hasOwnProperty","length","tooLongTotal","countTooLongSentences","getScore"],"sources":["../../../../src/scoring/assessments/readability/SentenceLengthInTextAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport Assessment from '../assessment';\nimport getTooLongSentences from '../../helpers/assessments/checkForTooLongSentences';\nimport formatNumber from '../../../helpers/formatNumber';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport {TextBlockIcon} from '@shopify/polaris-icons';\n\n/**\n * Represents the assessment that will calculate the length of sentences in the text.\n */\nclass SentenceLengthInTextAssessment extends Assessment {\n /**\n\t * Sets the identifier and the config.\n\t *\n\t * @param {object} config\t\t\tThe scoring configuration that should be used.\n\t * @param {boolean} isCornerstone\tWhether cornerstone configuration should be used.\n\t * @param {boolean} isProduct\t\tWhether product configuration should be used.\n\n\t * @returns {void}\n\t */\n constructor(config = {}, isCornerstone = false, isProduct = false) {\n super();\n\n const defaultConfig = {\n id: 'textSentenceLength',\n priority: 'high',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#sentence-length',\n ctaType: 'fix',\n fixPosition: 'sentenceLength',\n icon: TextBlockIcon,\n recommendedLength: 20,\n slightlyTooMany: 25,\n farTooMany: 30,\n title: 'Text Sentence Length',\n content: {\n improve: '',\n bad:\n 'Sentence too long. Keep sentence length less than 20 words to improve readability and flow.',\n good: 'Sentence length is optimized for readability, less than 20 words.'\n }\n };\n\n this._config = merge(defaultConfig, config);\n this.identifier = 'textSentenceLength';\n }\n\n /**\n * Scores the percentage of sentences including more than the recommended number of words.\n *\n * @param {Paper} paper The paper to use for the assessment.\n * @param {Researcher} researcher The researcher used for calling research.\n *\n * @param i18n\n * @returns {AssessmentResult} The Assessment result.\n */\n getResult({paper, researcher, i18n}) {\n const sentences = researcher.getResearch('countSentencesFromText');\n if (researcher.getConfig('sentenceLength')) {\n this._config = this.getLanguageSpecificConfig(researcher);\n }\n\n const percentage = this.calculatePercentage(sentences);\n const result = this.calculateResult(percentage, i18n);\n\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(result.score);\n assessmentResult.setStatus(result.status);\n assessmentResult.setBody(result.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks whether the paper has text.\n *\n * @param {Paper} paper The paper to use for the assessment.\n *\n * @returns {boolean} True when there is text.\n */\n isApplicable(paper) {\n return this.hasEnoughContentForAssessment(paper);\n }\n\n /**\n * Check if there is language-specific config, and if so, overwrite the current config with it.\n *\n * @param {Researcher} researcher The researcher to use.\n *\n * @returns {Object} The config that should be used.\n */\n getLanguageSpecificConfig(researcher) {\n const currentConfig = this._config;\n const languageSpecificConfig = researcher.getConfig('sentenceLength');\n\n if (languageSpecificConfig.hasOwnProperty('recommendedLength')) {\n currentConfig.recommendedLength = languageSpecificConfig.recommendedLength;\n }\n\n return currentConfig;\n }\n\n /**\n * Calculates the percentage of sentences that are too long.\n *\n * @param {Array} sentences The sentences to calculate the percentage for.\n * @returns {number} The calculates percentage of too long sentences.\n */\n calculatePercentage(sentences) {\n let percentage = 0;\n\n if (sentences.length !== 0) {\n const tooLongTotal = this.countTooLongSentences(sentences);\n\n percentage = formatNumber((tooLongTotal / sentences.length) * 100);\n }\n\n return percentage;\n }\n\n /**\n *\n * @param percentage\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(percentage, i18n) {\n let status = '';\n if (percentage <= this._config.recommendedLength) {\n status = 'good';\n }\n\n if (percentage > this._config.recommendedLength) {\n status = 'bad';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n this._config.content = {\n improve: '',\n bad: `Sentence too long. Keep sentence length less than ${this._config.recommendedLength} words to improve readability and flow.`,\n good: `Sentence length is optimized for readability, less than ${this._config.recommendedLength} words.`\n };\n\n return {\n score,\n status\n };\n }\n\n /**\n * Gets the sentences that are qualified as being too long.\n *\n * @param {array} sentences The sentences to filter through.\n * @returns {array} Array with all the sentences considered to be too long.\n */\n getTooLongSentences(sentences) {\n return getTooLongSentences(sentences, this._config.recommendedLength);\n }\n\n /**\n * Get the total amount of sentences that are qualified as being too long.\n *\n * @param {Array} sentences The sentences to filter through.\n * @returns {Number} The amount of sentences that are considered too long.\n */\n countTooLongSentences(sentences) {\n return this.getTooLongSentences(sentences).length;\n }\n}\n\nexport default SentenceLengthInTextAssessment;\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,UAAU;AACjB,OAAOC,mBAAmB;AAC1B,OAAOC,YAAY;AACnB,OAAOC,gBAAgB;AACvB,SAAQC,aAAa,QAAO,wBAAwB;;AAEpD;AACA;AACA;AACA,MAAMC,8BAA8B,SAASL,UAAU,CAAC;EACtD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EAEEM,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAEC,aAAa,GAAG,KAAK,EAAEC,SAAS,GAAG,KAAK,EAAE;IACjE,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,oBAAoB;MACxBC,QAAQ,EAAE,MAAM;MAChBC,MAAM,EACJ,6FAA6F;MAC/FC,OAAO,EAAE,KAAK;MACdC,WAAW,EAAE,gBAAgB;MAC7BC,IAAI,EAAEZ,aAAa;MACnBa,iBAAiB,EAAE,EAAE;MACrBC,eAAe,EAAE,EAAE;MACnBC,UAAU,EAAE,EAAE;MACdC,KAAK,EAAE,sBAAsB;MAC7BC,OAAO,EAAE;QACPC,OAAO,EAAE,EAAE;QACXC,GAAG,EACD,6FAA6F;QAC/FC,IAAI,EAAE;MACR;IACF,CAAC;IAED,IAAI,CAACC,OAAO,GAAG1B,KAAK,CAACW,aAAa,EAAEH,MAAM,CAAC;IAC3C,IAAI,CAACmB,UAAU,GAAG,oBAAoB;EACxC;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,SAASA,CAAC;IAACC,KAAK;IAAEC,UAAU;IAAEC;EAAI,CAAC,EAAE;IACnC,MAAMC,SAAS,GAAGF,UAAU,CAACG,WAAW,CAAC,wBAAwB,CAAC;IAClE,IAAIH,UAA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B,SAAS,CAAC;MAE1DI,UAAU,GAAGjC,YAAY,CAAEkD,YAAY,GAAGrB,SAAS,CAACoB,MAAM,GAAI,GAAG,CAAC;IACpE;IAEA,OAAOhB,UAAU;EACnB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEG,eAAeA,CAACH,UAAU,EAAEL,IAAI,EAAE;IAChC,IAAIa,MAAM,GAAG,EAAE;IACf,IAAIR,UAAU,IAAI,IAAI,CAACV,OAAO,CAACR,iBAAiB,EAAE;MAChD0B,MAAM,GAAG,MAAM;IACjB;IAEA,IAAIR,UAAU,GAAG,IAAI,CAACV,OAAO,CAACR,iBAAiB,EAAE;MAC/C0B,MAAM,GAAG,KAAK;IAChB;IAEA,MAAMF,KAAK,GAAG,IAAI,CAACa,QAAQ,CAAC,IAAI,CAAC7B,OAAO,CAACb,QAAQ,EAAE+B,MAAM,CAAC;IAE1D,IAAI,CAAClB,OAAO,CAACJ,OAAO,GAAG;MACrBC,OAAO,EAAE,EAAE;MACXC,GAAG,EAAE,qDAAqD,IAAI,CAACE,OAAO,CAACR,iBAAiB,yCAAyC;MACjIO,IAAI,EAAE,2DAA2D,IAAI,CAACC,OAAO,CAACR,iBAAiB;IACjG,CAAC;IAED,OAAO;MACLwB,KAAK;MACLE;IACF,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE1C,mBAAmBA,CAAC8B,SAAS,EAAE;IAC7B,OAAO9B,mBAAmB,CAAC8B,SAAS,EAAE,IAAI,CAACN,OAAO,CAACR,iBAAiB,CAAC;EACvE;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEoC,qBAAqBA,CAACtB,SAAS,EAAE;IAC/B,OAAO,IAAI,CAAC9B,mBAAmB,CAAC8B,SAAS,CAAC,CAACoB,MAAM;EACnD;AACF;AAEA,eAAe9C,8BAA8B","ignoreList":[]}
1
+ {"version":3,"file":"SentenceLengthInTextAssessment.js","names":["merge","Assessment","getTooLongSentences","formatNumber","AssessmentResult","TextBlockIcon","TEXT_SENTENCE_LENGTH_ID","SentenceLengthInTextAssessment","constructor","config","isCornerstone","isProduct","defaultConfig","id","priority","docUrl","ctaType","fixPosition","icon","recommendedLength","slightlyTooMany","farTooMany","title","content","improve","bad","good","_config","identifier","getResult","paper","researcher","i18n","sentences","getResearch","getConfig","getLanguageSpecificConfig","percentage","calculatePercentage","result","calculateResult","assessmentResult","setScore","score","setStatus","status","setBody","body","isApplicable","hasEnoughContentForAssessment","currentConfig","languageSpecificConfig","hasOwnProperty","length","tooLongTotal","countTooLongSentences","getScore"],"sources":["../../../../src/scoring/assessments/readability/SentenceLengthInTextAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport Assessment from '../assessment';\nimport getTooLongSentences from '../../helpers/assessments/checkForTooLongSentences';\nimport formatNumber from '../../../helpers/formatNumber';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport {TextBlockIcon} from '@shopify/polaris-icons';\nimport {TEXT_SENTENCE_LENGTH_ID} from '@axyseo/const/analysis';\n\n/**\n * Represents the assessment that will calculate the length of sentences in the text.\n */\nclass SentenceLengthInTextAssessment extends Assessment {\n /**\n\t * Sets the identifier and the config.\n\t *\n\t * @param {object} config\t\t\tThe scoring configuration that should be used.\n\t * @param {boolean} isCornerstone\tWhether cornerstone configuration should be used.\n\t * @param {boolean} isProduct\t\tWhether product configuration should be used.\n\n\t * @returns {void}\n\t */\n constructor(config = {}, isCornerstone = false, isProduct = false) {\n super();\n\n const defaultConfig = {\n id: TEXT_SENTENCE_LENGTH_ID,\n priority: 'high',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#sentence-length',\n ctaType: 'fix',\n fixPosition: 'sentenceLength',\n icon: TextBlockIcon,\n recommendedLength: 20,\n slightlyTooMany: 25,\n farTooMany: 30,\n title: 'Text Sentence Length',\n content: {\n improve: '',\n bad:\n 'Sentence too long. Keep sentence length less than 20 words to improve readability and flow.',\n good: 'Sentence length is optimized for readability, less than 20 words.'\n }\n };\n\n this._config = merge(defaultConfig, config);\n this.identifier = TEXT_SENTENCE_LENGTH_ID;\n }\n\n /**\n * Scores the percentage of sentences including more than the recommended number of words.\n *\n * @param {Paper} paper The paper to use for the assessment.\n * @param {Researcher} researcher The researcher used for calling research.\n *\n * @param i18n\n * @returns {AssessmentResult} The Assessment result.\n */\n getResult({paper, researcher, i18n}) {\n const sentences = researcher.getResearch('countSentencesFromText');\n if (researcher.getConfig('sentenceLength')) {\n this._config = this.getLanguageSpecificConfig(researcher);\n }\n\n const percentage = this.calculatePercentage(sentences);\n const result = this.calculateResult(percentage, i18n);\n\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(result.score);\n assessmentResult.setStatus(result.status);\n assessmentResult.setBody(result.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks whether the paper has text.\n *\n * @param {Paper} paper The paper to use for the assessment.\n *\n * @returns {boolean} True when there is text.\n */\n isApplicable(paper) {\n return this.hasEnoughContentForAssessment(paper);\n }\n\n /**\n * Check if there is language-specific config, and if so, overwrite the current config with it.\n *\n * @param {Researcher} researcher The researcher to use.\n *\n * @returns {Object} The config that should be used.\n */\n getLanguageSpecificConfig(researcher) {\n const currentConfig = this._config;\n const languageSpecificConfig = researcher.getConfig('sentenceLength');\n\n if (languageSpecificConfig.hasOwnProperty('recommendedLength')) {\n currentConfig.recommendedLength = languageSpecificConfig.recommendedLength;\n }\n\n return currentConfig;\n }\n\n /**\n * Calculates the percentage of sentences that are too long.\n *\n * @param {Array} sentences The sentences to calculate the percentage for.\n * @returns {number} The calculates percentage of too long sentences.\n */\n calculatePercentage(sentences) {\n let percentage = 0;\n\n if (sentences.length !== 0) {\n const tooLongTotal = this.countTooLongSentences(sentences);\n\n percentage = formatNumber((tooLongTotal / sentences.length) * 100);\n }\n\n return percentage;\n }\n\n /**\n *\n * @param percentage\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(percentage, i18n) {\n let status = '';\n if (percentage <= this._config.recommendedLength) {\n status = 'good';\n }\n\n if (percentage > this._config.recommendedLength) {\n status = 'bad';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n this._config.content = {\n improve: '',\n bad: `Sentence too long. Keep sentence length less than ${this._config.recommendedLength} words to improve readability and flow.`,\n good: `Sentence length is optimized for readability, less than ${this._config.recommendedLength} words.`\n };\n\n return {\n score,\n status\n };\n }\n\n /**\n * Gets the sentences that are qualified as being too long.\n *\n * @param {array} sentences The sentences to filter through.\n * @returns {array} Array with all the sentences considered to be too long.\n */\n getTooLongSentences(sentences) {\n return getTooLongSentences(sentences, this._config.recommendedLength);\n }\n\n /**\n * Get the total amount of sentences that are qualified as being too long.\n *\n * @param {Array} sentences The sentences to filter through.\n * @returns {Number} The amount of sentences that are considered too long.\n */\n countTooLongSentences(sentences) {\n return this.getTooLongSentences(sentences).length;\n }\n}\n\nexport default SentenceLengthInTextAssessment;\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,UAAU;AACjB,OAAOC,mBAAmB;AAC1B,OAAOC,YAAY;AACnB,OAAOC,gBAAgB;AACvB,SAAQC,aAAa,QAAO,wBAAwB;AACpD,SAAQC,uBAAuB;;AAE/B;AACA;AACA;AACA,MAAMC,8BAA8B,SAASN,UAAU,CAAC;EACtD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EAEEO,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAEC,aAAa,GAAG,KAAK,EAAEC,SAAS,GAAG,KAAK,EAAE;IACjE,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAEP,uBAAuB;MAC3BQ,QAAQ,EAAE,MAAM;MAChBC,MAAM,EACJ,6FAA6F;MAC/FC,OAAO,EAAE,KAAK;MACdC,WAAW,EAAE,gBAAgB;MAC7BC,IAAI,EAAEb,aAAa;MACnBc,iBAAiB,EAAE,EAAE;MACrBC,eAAe,EAAE,EAAE;MACnBC,UAAU,EAAE,EAAE;MACdC,K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;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE3C,mBAAmBA,CAAC+B,SAAS,EAAE;IAC7B,OAAO/B,mBAAmB,CAAC+B,SAAS,EAAE,IAAI,CAACN,OAAO,CAACR,iBAAiB,CAAC;EACvE;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEoC,qBAAqBA,CAACtB,SAAS,EAAE;IAC/B,OAAO,IAAI,CAAC/B,mBAAmB,CAAC+B,SAAS,CAAC,CAACoB,MAAM;EACnD;AACF;AAEA,eAAe9C,8BAA8B","ignoreList":[]}
@@ -6,6 +6,7 @@ import Assessment from "../assessment";
6
6
  import removeHtmlBlocks from "../../../languageProcessing/helpers/html/htmlParser";
7
7
  import getWords from "../../../languageProcessing/helpers/word/getWords";
8
8
  import { filterShortcodesFromHTML } from "../../../languageProcessing/helpers";
9
+ import { TEXT_TRANSITION_WORDS_ID } from "../../../const/analysis";
9
10
 
10
11
  /**
11
12
  * Represents the assessment that checks whether there are enough transition words in the text.
@@ -21,7 +22,7 @@ export default class TransitionWordsAssessment extends Assessment {
21
22
  constructor(config = {}) {
22
23
  super();
23
24
  const defaultConfig = {
24
- id: 'textTransitionWords',
25
+ id: TEXT_TRANSITION_WORDS_ID,
25
26
  fixPosition: 'longestParagraph',
26
27
  ctaType: 'fix',
27
28
  docUrl: 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#use-of-transition-words',
@@ -34,7 +35,7 @@ export default class TransitionWordsAssessment extends Assessment {
34
35
  improve: ''
35
36
  }
36
37
  };
37
- this.identifier = 'textTransitionWords';
38
+ this.identifier = TEXT_TRANSITION_WORDS_ID;
38
39
  this._config = merge(defaultConfig, config);
39
40
  }
40
41
 
@@ -1 +1 @@
1
- {"version":3,"file":"TransitionWordsAssessment.js","names":["merge","formatNumber","inRangeStartInclusive","inRange","AssessmentResult","Assessment","removeHtmlBlocks","getWords","filterShortcodesFromHTML","TransitionWordsAssessment","constructor","config","defaultConfig","id","fixPosition","ctaType","docUrl","priority","applicableIfTextLongerThan","title","content","good","bad","improve","identifier","_config","calculateTransitionWordPercentage","sentences","transitionWordSentences","totalSentences","calculateScoreFromPercentage","percentage","calculateTransitionWordResult","i18n","score","status","customScore","getScore","getResult","paper","researcher","getResearch","transitionWordResult","assessmentResult","setScore","setStatus","setBody","body","isApplicable","customCountLength","getHelper","customApplicabilityConfig","getConfig","transitionWords","text","getText","_attributes","shortcodes","textLength","length","hasResearch"],"sources":["../../../../src/scoring/assessments/readability/TransitionWordsAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport formatNumber from '../../../helpers/formatNumber';\nimport {inRangeStartInclusive as inRange} from '../../helpers/assessments/inRange';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\nimport removeHtmlBlocks from '@axyseo/languageProcessing/helpers/html/htmlParser';\nimport getWords from '@axyseo/languageProcessing/helpers/word/getWords';\nimport {filterShortcodesFromHTML} from '@axyseo/languageProcessing/helpers';\n\n/**\n * Represents the assessment that checks whether there are enough transition words in the text.\n */\nexport default class TransitionWordsAssessment 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: 'textTransitionWords',\n fixPosition: 'longestParagraph',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#use-of-transition-words',\n priority: 'low',\n applicableIfTextLongerThan: 200,\n title: 'Use of transition words',\n content: {\n good: 'Transition words are used effectively.',\n bad:\n 'Lack of transition words. Improve readability and flow by adding words like \"however,\" \"also,\" etc.',\n improve: ''\n }\n };\n\n this.identifier = 'textTransitionWords';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Calculates the actual percentage of transition words in the sentences.\n *\n * @param {object} sentences The object containing the total number of sentences and the number of sentences containing\n * a transition word.\n *\n * @returns {number} The percentage of sentences containing a transition word.\n */\n calculateTransitionWordPercentage(sentences) {\n if (sentences.transitionWordSentences === 0 || sentences.totalSentences === 0) {\n return 0;\n }\n\n return formatNumber((sentences.transitionWordSentences / sentences.totalSentences) * 100);\n }\n\n /**\n * Calculates the score for the assessment based on the percentage of sentences containing transition words.\n *\n * @param {number} percentage The percentage of sentences containing transition words.\n *\n * @returns {number} The score.\n */\n calculateScoreFromPercentage(percentage) {\n if (percentage < 10) {\n // Red indicator.\n return 3;\n }\n\n if (inRange(percentage, 10, 20)) {\n // Orange indicator.\n return 6;\n }\n\n // Green indicator.\n return 9;\n }\n\n /**\n *\n * @param transitionWordSentences\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateTransitionWordResult(transitionWordSentences, i18n) {\n const percentage = this.calculateTransitionWordPercentage(transitionWordSentences);\n const score = this.calculateScoreFromPercentage(percentage);\n\n let status = 'good';\n if (score < 6 || percentage === 0) {\n status = 'bad';\n }\n\n const customScore = this.getScore(this._config.priority, status);\n\n return {\n score: customScore,\n status\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const transitionWordSentences = researcher.getResearch('findTransitionWords');\n const transitionWordResult = this.calculateTransitionWordResult(transitionWordSentences, i18n);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(transitionWordResult.score);\n assessmentResult.setStatus(transitionWordResult.status);\n assessmentResult.setBody(transitionWordResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the transition words assessment is applicable to the paper. Language-specific length requirements and methods of counting text length\n * may apply (e.g. for Japanese, the text should be counted in characters instead of words, which also makes the minimum required length higher).\n *\n * @param {Paper} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available, the paper is not empty and the text is longer than the minimum required length.\n */\n isApplicable(paper, researcher) {\n const customCountLength = researcher.getHelper('customCountLength');\n const customApplicabilityConfig = researcher.getConfig('assessmentApplicability')\n .transitionWords;\n if (customApplicabilityConfig) {\n this._config.applicableIfTextLongerThan = customApplicabilityConfig;\n }\n let text = paper.getText();\n text = removeHtmlBlocks(text);\n text = filterShortcodesFromHTML(text, paper._attributes && paper._attributes.shortcodes);\n const textLength = customCountLength ? customCountLength(text) : getWords(text).length;\n\n // Do not use hasEnoughContent in this assessment as it is mostly redundant with `textLength >= this._config.applicableIfTextLongerThan`\n return (\n textLength >= this._config.applicableIfTextLongerThan &&\n researcher.hasResearch('findTransitionWords')\n );\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,YAAY;AACnB,SAAQC,qBAAqB,IAAIC,OAAO;AACxC,OAAOC,gBAAgB;AACvB,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AACvB,OAAOC,QAAQ;AACf,SAAQC,wBAAwB;;AAEhC;AACA;AACA;AACA,eAAe,MAAMC,yBAAyB,SAASJ,UAAU,CAAC;EAChE;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,qBAAqB;MACzBC,WAAW,EAAE,kBAAkB;MAC/BC,OAAO,EAAE,KAAK;MACdC,MAAM,EACJ,qGAAqG;MACvGC,QAAQ,EAAE,KAAK;MACfC,0BAA0B,EAAE,GAAG;MAC/BC,KAAK,EAAE,yBAAyB;MAChCC,OAAO,EAAE;QACPC,IAAI,EAAE,wCAAwC;QAC9CC,GAAG,EACD,qGAAqG;QACvGC,OAAO,EAAE;MACX;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAG,qBAAqB;IACvC,IAAI,CAACC,OAAO,GAAGzB,KAAK,CAACY,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEe,iCAAiCA,CAACC,SAAS,EAAE;IAC3C,IAAIA,SAAS,CAACC,uBAAuB,KAAK,CA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AgB,CAAC;MAACO,MAAM,EAAE,IAAI,CAACc;IAAO,CAAC,CAAC;IAErEkB,gBAAgB,CAACC,QAAQ,CAACF,oBAAoB,CAACR,KAAK,CAAC;IACrDS,gBAAgB,CAACE,SAAS,CAACH,oBAAoB,CAACP,MAAM,CAAC;IACvDQ,gBAAgB,CAACG,OAAO,CAACJ,oBAAoB,CAACK,IAAI,CAAC;IAEnD,OAAOJ,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEK,YAAYA,CAACT,KAAK,EAAEC,UAAU,EAAE;IAC9B,MAAMS,iBAAiB,GAAGT,UAAU,CAACU,SAAS,CAAC,mBAAmB,CAAC;IACnE,MAAMC,yBAAyB,GAAGX,UAAU,CAACY,SAAS,CAAC,yBAAyB,CAAC,CAC9EC,eAAe;IAClB,IAAIF,yBAAyB,EAAE;MAC7B,IAAI,CAAC1B,OAAO,CAACP,0BAA0B,GAAGiC,yBAAyB;IACrE;IACA,IAAIG,IAAI,GAAGf,KAAK,CAACgB,OAAO,CAAC,CAAC;IAC1BD,IAAI,GAAGhD,gBAAgB,CAACgD,IAAI,CAAC;IAC7BA,IAAI,GAAG9C,wBAAwB,CAAC8C,IAAI,EAAEf,KAAK,CAACiB,WAAW,IAAIjB,KAAK,CAACiB,WAAW,CAACC,UAAU,CAAC;IACxF,MAAMC,UAAU,GAAGT,iBAAiB,GAAGA,iBAAiB,CAACK,IAAI,CAAC,GAAG/C,QAAQ,CAAC+C,IAAI,CAAC,CAACK,MAAM;;IAEtF;IACA,OACED,UAAU,IAAI,IAAI,CAACjC,OAAO,CAACP,0BAA0B,IACrDsB,UAAU,CAACoB,WAAW,CAAC,qBAAqB,CAAC;EAEjD;AACF","ignoreList":[]}
1
+ {"version":3,"file":"TransitionWordsAssessment.js","names":["merge","formatNumber","inRangeStartInclusive","inRange","AssessmentResult","Assessment","removeHtmlBlocks","getWords","filterShortcodesFromHTML","TEXT_TRANSITION_WORDS_ID","TransitionWordsAssessment","constructor","config","defaultConfig","id","fixPosition","ctaType","docUrl","priority","applicableIfTextLongerThan","title","content","good","bad","improve","identifier","_config","calculateTransitionWordPercentage","sentences","transitionWordSentences","totalSentences","calculateScoreFromPercentage","percentage","calculateTransitionWordResult","i18n","score","status","customScore","getScore","getResult","paper","researcher","getResearch","transitionWordResult","assessmentResult","setScore","setStatus","setBody","body","isApplicable","customCountLength","getHelper","customApplicabilityConfig","getConfig","transitionWords","text","getText","_attributes","shortcodes","textLength","length","hasResearch"],"sources":["../../../../src/scoring/assessments/readability/TransitionWordsAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport formatNumber from '../../../helpers/formatNumber';\nimport {inRangeStartInclusive as inRange} from '../../helpers/assessments/inRange';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\nimport removeHtmlBlocks from '@axyseo/languageProcessing/helpers/html/htmlParser';\nimport getWords from '@axyseo/languageProcessing/helpers/word/getWords';\nimport {filterShortcodesFromHTML} from '@axyseo/languageProcessing/helpers';\nimport {TEXT_TRANSITION_WORDS_ID} from '@axyseo/const/analysis';\n\n/**\n * Represents the assessment that checks whether there are enough transition words in the text.\n */\nexport default class TransitionWordsAssessment 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: TEXT_TRANSITION_WORDS_ID,\n fixPosition: 'longestParagraph',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#use-of-transition-words',\n priority: 'low',\n applicableIfTextLongerThan: 200,\n title: 'Use of transition words',\n content: {\n good: 'Transition words are used effectively.',\n bad:\n 'Lack of transition words. Improve readability and flow by adding words like \"however,\" \"also,\" etc.',\n improve: ''\n }\n };\n\n this.identifier = TEXT_TRANSITION_WORDS_ID;\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Calculates the actual percentage of transition words in the sentences.\n *\n * @param {object} sentences The object containing the total number of sentences and the number of sentences containing\n * a transition word.\n *\n * @returns {number} The percentage of sentences containing a transition word.\n */\n calculateTransitionWordPercentage(sentences) {\n if (sentences.transitionWordSentences === 0 || sentences.totalSentences === 0) {\n return 0;\n }\n\n return formatNumber((sentences.transitionWordSentences / sentences.totalSentences) * 100);\n }\n\n /**\n * Calculates the score for the assessment based on the percentage of sentences containing transition words.\n *\n * @param {number} percentage The percentage of sentences containing transition words.\n *\n * @returns {number} The score.\n */\n calculateScoreFromPercentage(percentage) {\n if (percentage < 10) {\n // Red indicator.\n return 3;\n }\n\n if (inRange(percentage, 10, 20)) {\n // Orange indicator.\n return 6;\n }\n\n // Green indicator.\n return 9;\n }\n\n /**\n *\n * @param transitionWordSentences\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateTransitionWordResult(transitionWordSentences, i18n) {\n const percentage = this.calculateTransitionWordPercentage(transitionWordSentences);\n const score = this.calculateScoreFromPercentage(percentage);\n\n let status = 'good';\n if (score < 6 || percentage === 0) {\n status = 'bad';\n }\n\n const customScore = this.getScore(this._config.priority, status);\n\n return {\n score: customScore,\n status\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const transitionWordSentences = researcher.getResearch('findTransitionWords');\n const transitionWordResult = this.calculateTransitionWordResult(transitionWordSentences, i18n);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(transitionWordResult.score);\n assessmentResult.setStatus(transitionWordResult.status);\n assessmentResult.setBody(transitionWordResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the transition words assessment is applicable to the paper. Language-specific length requirements and methods of counting text length\n * may apply (e.g. for Japanese, the text should be counted in characters instead of words, which also makes the minimum required length higher).\n *\n * @param {Paper} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available, the paper is not empty and the text is longer than the minimum required length.\n */\n isApplicable(paper, researcher) {\n const customCountLength = researcher.getHelper('customCountLength');\n const customApplicabilityConfig = researcher.getConfig('assessmentApplicability')\n .transitionWords;\n if (customApplicabilityConfig) {\n this._config.applicableIfTextLongerThan = customApplicabilityConfig;\n }\n let text = paper.getText();\n text = removeHtmlBlocks(text);\n text = filterShortcodesFromHTML(text, paper._attributes && paper._attributes.shortcodes);\n const textLength = customCountLength ? customCountLength(text) : getWords(text).length;\n\n // Do not use hasEnoughContent in this assessment as it is mostly redundant with `textLength >= this._config.applicableIfTextLongerThan`\n return (\n textLength >= this._config.applicableIfTextLongerThan &&\n researcher.hasResearch('findTransitionWords')\n );\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,YAAY;AACnB,SAAQC,qBAAqB,IAAIC,OAAO;AACxC,OAAOC,gBAAgB;AACvB,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AACvB,OAAOC,QAAQ;AACf,SAAQC,wBAAwB;AAChC,SAAQC,wBAAwB;;AAEhC;AACA;AACA;AACA,eAAe,MAAMC,yBAAyB,SAASL,UAAU,CAAC;EAChE;AACF;AACA;AACA;AACA;AACA;AACA;EACEM,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAEL,wBAAwB;MAC5BM,WAAW,EAAE,kBAAkB;MAC/BC,OAAO,EAAE,KAAK;MACdC,MAAM,EACJ,qGAAqG;MACvGC,QAAQ,EAAE,KAAK;MACfC,0BAA0B,EAAE,GAAG;MAC/BC,KAAK,EAAE,yBAAyB;MAChCC,OAAO,EAAE;QACPC,IAAI,EAAE,wCAAwC;QAC9CC,GAAG,EACD,qGAAqG;QACvGC,OAAO,EAAE;MACX;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAGhB,wBAAwB;IAC1C,IAAI,CAACiB,OAAO,GAAG1B,KAAK,CAACa,aAAa,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-1,6 +1,7 @@
1
1
  import { merge } from 'lodash';
2
2
  import Assessment from "../assessment";
3
3
  import AssessmentResult from "../../../values/AssessmentResult";
4
+ import { MEDIA_ID } from "../../../const/analysis";
4
5
 
5
6
  /**
6
7
  * Represents the assessment that checks if the text has any images present, including videos in product pages.
@@ -17,7 +18,7 @@ export default class TextImagesAssessment extends Assessment {
17
18
  constructor(config = {}, countVideos = true) {
18
19
  super();
19
20
  const defaultConfig = {
20
- id: 'media',
21
+ id: MEDIA_ID,
21
22
  docUrl: 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#images-and-videos',
22
23
  priority: 'high',
23
24
  fixPosition: 'description',
@@ -28,7 +29,7 @@ export default class TextImagesAssessment extends Assessment {
28
29
  bad: 'No media found. Add visual content to enhance engagement.'
29
30
  }
30
31
  };
31
- this.identifier = 'media';
32
+ this.identifier = MEDIA_ID;
32
33
  this._config = merge(defaultConfig, config);
33
34
  this._countVideos = countVideos;
34
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ImageCountAssessment.js","names":["merge","Assessment","AssessmentResult","TextImagesAssessment","constructor","config","countVideos","defaultConfig","id","docUrl","priority","fixPosition","title","content","good","improve","bad","identifier","_config","_countVideos","getResult","paper","researcher","i18n","imageCount","getResearch","videoCount","assessmentResult","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","isApplicable","hasText","mediaCount","getScore"],"sources":["../../../../src/scoring/assessments/seo/ImageCountAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\n\n/**\n * Represents the assessment that checks if the text has any images present, including videos in product pages.\n */\nexport default class TextImagesAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {object} config The configuration to use.\n * @param {boolean} countVideos Whether videos are also included in the assessment or not.\n *\n * @returns {void}\n */\n constructor(config = {}, countVideos = true) {\n super();\n\n const defaultConfig = {\n id: 'media',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#images-and-videos',\n priority: 'high',\n fixPosition: 'description',\n title: 'Media',\n content: {\n good: 'Media are used effectively.',\n improve: '',\n bad: 'No media found. Add visual content to enhance engagement.'\n }\n };\n\n this.identifier = 'media';\n this._config = merge(defaultConfig, config);\n this._countVideos = countVideos;\n }\n\n /**\n * Execute the Assessment and return 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 this.imageCount = researcher.getResearch('imageCount');\n this.videoCount = researcher.getResearch('videoCount');\n\n const assessmentResult = new AssessmentResult({config: this._config});\n\n const calculatedResult = this.calculateResult(i18n);\n\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks whether the paper has text.\n *\n * @param {Paper} paper The paper to use for the assessment.\n *\n * @returns {boolean} True when there is text.\n */\n isApplicable(paper) {\n return paper.hasText();\n }\n\n /**\n * Calculate the result based on the availability of images in the text, including videos in product pages.\n *\n * @returns {Object} The calculated result.\n */\n calculateResult(i18n) {\n // If \"countVideos\" is on, we include videos in the assessment\n const mediaCount = this._countVideos ? this.imageCount + this.videoCount : this.imageCount;\n\n let status = '';\n // No images.\n if (mediaCount === 0) {\n status = 'bad';\n } else {\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;;AAEvB;AACA;AACA;AACA,eAAe,MAAMC,oBAAoB,SAASF,UAAU,CAAC;EAC3D;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEG,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAEC,WAAW,G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CAACN,IAAI,EAAE;IACpB;IACA,MAAMe,UAAU,GAAG,IAAI,CAACnB,YAAY,GAAG,IAAI,CAACK,UAAU,GAAG,IAAI,CAACE,UAAU,GAAG,IAAI,CAACF,UAAU;IAE1F,IAAIS,MAAM,GAAG,EAAE;IACf;IACA,IAAIK,UAAU,KAAK,CAAC,EAAE;MACpBL,MAAM,GAAG,KAAK;IAChB,CAAC,MAAM;MACLA,MAAM,GAAG,MAAM;IACjB;IAEA,MAAMF,KAAK,GAAG,IAAI,CAACQ,QAAQ,CAAC,IAAI,CAACrB,OAAO,CAACR,QAAQ,EAAEuB,MAAM,CAAC;IAE1D,OAAO;MACLF,KAAK;MACLE;IACF,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"file":"ImageCountAssessment.js","names":["merge","Assessment","AssessmentResult","MEDIA_ID","TextImagesAssessment","constructor","config","countVideos","defaultConfig","id","docUrl","priority","fixPosition","title","content","good","improve","bad","identifier","_config","_countVideos","getResult","paper","researcher","i18n","imageCount","getResearch","videoCount","assessmentResult","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","isApplicable","hasText","mediaCount","getScore"],"sources":["../../../../src/scoring/assessments/seo/ImageCountAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport {MEDIA_ID} from '@axyseo/const/analysis';\n\n/**\n * Represents the assessment that checks if the text has any images present, including videos in product pages.\n */\nexport default class TextImagesAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {object} config The configuration to use.\n * @param {boolean} countVideos Whether videos are also included in the assessment or not.\n *\n * @returns {void}\n */\n constructor(config = {}, countVideos = true) {\n super();\n\n const defaultConfig = {\n id: MEDIA_ID,\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#images-and-videos',\n priority: 'high',\n fixPosition: 'description',\n title: 'Media',\n content: {\n good: 'Media are used effectively.',\n improve: '',\n bad: 'No media found. Add visual content to enhance engagement.'\n }\n };\n\n this.identifier = MEDIA_ID;\n this._config = merge(defaultConfig, config);\n this._countVideos = countVideos;\n }\n\n /**\n * Execute the Assessment and return 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 this.imageCount = researcher.getResearch('imageCount');\n this.videoCount = researcher.getResearch('videoCount');\n\n const assessmentResult = new AssessmentResult({config: this._config});\n\n const calculatedResult = this.calculateResult(i18n);\n\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks whether the paper has text.\n *\n * @param {Paper} paper The paper to use for the assessment.\n *\n * @returns {boolean} True when there is text.\n */\n isApplicable(paper) {\n return paper.hasText();\n }\n\n /**\n * Calculate the result based on the availability of images in the text, including videos in product pages.\n *\n * @returns {Object} The calculated result.\n */\n calculateResult(i18n) {\n // If \"countVideos\" is on, we include videos in the assessment\n const mediaCount = this._countVideos ? this.imageCount + this.videoCount : this.imageCount;\n\n let status = '';\n // No images.\n if (mediaCount === 0) {\n status = 'bad';\n } else {\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,SAAQC,QAAQ;;AAEhB;AACA;AACA;AACA,eAAe,MAAMC,oBAAoB,SAASH,UAAU,CAAC;EAC3D;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEI,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAEC,WAAW,GAAG,IAAI,EAAE;IAC3C,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAEN,QA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ACK,UAAU,GAAG,IAAI,CAACE,UAAU,GAAG,IAAI,CAACF,UAAU;IAE1F,IAAIS,MAAM,GAAG,EAAE;IACf;IACA,IAAIK,UAAU,KAAK,CAAC,EAAE;MACpBL,MAAM,GAAG,KAAK;IAChB,CAAC,MAAM;MACLA,MAAM,GAAG,MAAM;IACjB;IAEA,MAAMF,KAAK,GAAG,IAAI,CAACQ,QAAQ,CAAC,IAAI,CAACrB,OAAO,CAACR,QAAQ,EAAEuB,MAAM,CAAC;IAE1D,OAAO;MACLF,KAAK;MACLE;IACF,CAAC;EACH;AACF","ignoreList":[]}
@@ -2,6 +2,7 @@ import { merge } from 'lodash';
2
2
  import Assessment from "../assessment";
3
3
  import AssessmentResult from "../../../values/AssessmentResult";
4
4
  import { LinkIcon } from '@shopify/polaris-icons';
5
+ import { INTERNAL_LINKS_ID } from "../../../const/analysis";
5
6
 
6
7
  /**
7
8
  * Assessment to check whether the text has internal links and whether they are followed or no-followed.
@@ -23,7 +24,7 @@ class InternalLinksAssessment extends Assessment {
23
24
  constructor(config = {}) {
24
25
  super();
25
26
  const defaultConfig = {
26
- id: 'internalLinks',
27
+ id: INTERNAL_LINKS_ID,
27
28
  fixPosition: '',
28
29
  docUrl: 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#internal-links-outbound-links',
29
30
  icon: LinkIcon,
@@ -35,7 +36,7 @@ class InternalLinksAssessment extends Assessment {
35
36
  bad: 'No internal links found. Add links to other relevant pages on your website.'
36
37
  }
37
38
  };
38
- this.identifier = 'internalLinks';
39
+ this.identifier = INTERNAL_LINKS_ID;
39
40
  this._config = merge(defaultConfig, config);
40
41
  }
41
42