axyseo 2.0.0-alpha.0.0.60 → 2.0.0-alpha.0.0.62

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 (57) hide show
  1. package/build/languageProcessing/researches/getSentenceBeginnings.js +2 -0
  2. package/build/languageProcessing/researches/getSentenceBeginnings.js.map +1 -1
  3. package/build/scoring/assessments/readability/ParagraphTooLongAssessment.js +4 -11
  4. package/build/scoring/assessments/readability/ParagraphTooLongAssessment.js.map +1 -1
  5. package/build/scoring/assessments/readability/RelatedKeywordsAssessment.js +4 -7
  6. package/build/scoring/assessments/readability/RelatedKeywordsAssessment.js.map +1 -1
  7. package/build/scoring/assessments/readability/SentenceBeginningsAssessment.js +6 -8
  8. package/build/scoring/assessments/readability/SentenceBeginningsAssessment.js.map +1 -1
  9. package/build/scoring/assessments/readability/SentenceLengthInTextAssessment.js +4 -8
  10. package/build/scoring/assessments/readability/SentenceLengthInTextAssessment.js.map +1 -1
  11. package/build/scoring/assessments/readability/TransitionWordsAssessment.js +4 -8
  12. package/build/scoring/assessments/readability/TransitionWordsAssessment.js.map +1 -1
  13. package/build/scoring/assessments/seo/ImageCountAssessment.js +4 -9
  14. package/build/scoring/assessments/seo/ImageCountAssessment.js.map +1 -1
  15. package/build/scoring/assessments/seo/InternalLinksAssessment.js +4 -8
  16. package/build/scoring/assessments/seo/InternalLinksAssessment.js.map +1 -1
  17. package/build/scoring/assessments/seo/IntroductionKeywordAssessment.js +4 -8
  18. package/build/scoring/assessments/seo/IntroductionKeywordAssessment.js.map +1 -1
  19. package/build/scoring/assessments/seo/KeyphraseAssessment.js +4 -8
  20. package/build/scoring/assessments/seo/KeyphraseAssessment.js.map +1 -1
  21. package/build/scoring/assessments/seo/KeyphraseLengthAssessment.js +3 -5
  22. package/build/scoring/assessments/seo/KeyphraseLengthAssessment.js.map +1 -1
  23. package/build/scoring/assessments/seo/KeywordDensityAssessment.js +4 -7
  24. package/build/scoring/assessments/seo/KeywordDensityAssessment.js.map +1 -1
  25. package/build/scoring/assessments/seo/MetaDescriptionKeywordAssessment.js +4 -7
  26. package/build/scoring/assessments/seo/MetaDescriptionKeywordAssessment.js.map +1 -1
  27. package/build/scoring/assessments/seo/MetaDescriptionLengthAssessment.js +4 -7
  28. package/build/scoring/assessments/seo/MetaDescriptionLengthAssessment.js.map +1 -1
  29. package/build/scoring/assessments/seo/MetaTitleKeywordAssessment.js +4 -12
  30. package/build/scoring/assessments/seo/MetaTitleKeywordAssessment.js.map +1 -1
  31. package/build/scoring/assessments/seo/NumberInMetaTitleAssessment.js +3 -6
  32. package/build/scoring/assessments/seo/NumberInMetaTitleAssessment.js.map +1 -1
  33. package/build/scoring/assessments/seo/OutboundLinksAssessment.js +4 -7
  34. package/build/scoring/assessments/seo/OutboundLinksAssessment.js.map +1 -1
  35. package/build/scoring/assessments/seo/PageTitleWidthAssessment.js +4 -7
  36. package/build/scoring/assessments/seo/PageTitleWidthAssessment.js.map +1 -1
  37. package/build/scoring/assessments/seo/SchemaAssessment.js +4 -8
  38. package/build/scoring/assessments/seo/SchemaAssessment.js.map +1 -1
  39. package/build/scoring/assessments/seo/SingleH1Assessment.js +5 -7
  40. package/build/scoring/assessments/seo/SingleH1Assessment.js.map +1 -1
  41. package/build/scoring/assessments/seo/SingleTitleAssessment.js +5 -7
  42. package/build/scoring/assessments/seo/SingleTitleAssessment.js.map +1 -1
  43. package/build/scoring/assessments/seo/SubHeadingsKeywordAssessment.js +4 -8
  44. package/build/scoring/assessments/seo/SubHeadingsKeywordAssessment.js.map +1 -1
  45. package/build/scoring/assessments/seo/TextImagesAssessment.js +4 -8
  46. package/build/scoring/assessments/seo/TextImagesAssessment.js.map +1 -1
  47. package/build/scoring/assessments/seo/TextLengthAssessment.js +4 -7
  48. package/build/scoring/assessments/seo/TextLengthAssessment.js.map +1 -1
  49. package/build/scoring/assessments/seo/UrlKeywordAssessment.js +4 -8
  50. package/build/scoring/assessments/seo/UrlKeywordAssessment.js.map +1 -1
  51. package/build/scoring/assessments/seo/UrlLengthAssessment.js +4 -7
  52. package/build/scoring/assessments/seo/UrlLengthAssessment.js.map +1 -1
  53. package/build/scoring/assessors/avadaAssessor.js +1 -0
  54. package/build/scoring/assessors/avadaAssessor.js.map +1 -1
  55. package/build/values/AssessmentResult.js +12 -30
  56. package/build/values/AssessmentResult.js.map +1 -1
  57. package/package.json +1 -1
@@ -5,6 +5,7 @@ import { stripFullTags as stripTags } from "../helpers/sanitize/stripHTMLTags.js
5
5
  import { filter, forEach, isEmpty } from 'lodash';
6
6
  import removeHtmlBlocks from "../helpers/html/htmlParser";
7
7
  import { filterShortcodesFromHTML } from "../helpers";
8
+ import stripNonTextTags from "../helpers/sanitize/stripNonTextTags";
8
9
 
9
10
  /**
10
11
  * Compares the first word of each sentence with the first word of the following sentence.
@@ -92,6 +93,7 @@ export default function (paper, researcher) {
92
93
  const memoizedTokenizer = researcher.getHelper('memoizedTokenizer');
93
94
  let text = paper.getText();
94
95
  text = removeHtmlBlocks(text);
96
+ text = stripNonTextTags(text);
95
97
  text = filterShortcodesFromHTML(text, paper._attributes && paper._attributes.shortcodes);
96
98
 
97
99
  // Remove any HTML whitespace padding and replace it with a single whitespace.
@@ -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 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(sentenceB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AiB,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
+ {"version":3,"file":"getSentenceBeginnings.js","names":["getWords","getSentences","stripSpaces","stripFullTags","stripTags","filter","forEach","isEmpty","removeHtmlBlocks","filterShortcodesFromHTML","stripNonTextTags","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';\nimport stripNonTextTags from '@axyseo/languageProcessing/helpers/sanitize/stripNonTextTags';\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 = stripNonTextTags(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;AAChC,OAAOC,gBAAgB;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG,SAAAA,CAASC,wBAAwB,EAAEC,qBAAqB,EAAE;EACnF,OAAO,CAACN,OAAO,CAACK,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;EAEtBb,OAAO,CAACS,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,IA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,GAAG5B,WAAW,CAACwB,QAAQ,CAAC;IACtC,MAAMK,KAAK,GAAGF,oBAAoB,GAAGA,oBAAoB,CAACC,QAAQ,CAAC,GAAG9B,QAAQ,CAAC8B,QAAQ,CAAC;IACxF,OAAOC,KAAK,CAACE,MAAM,GAAG,CAAC;EACzB,CAAC,CAAC;EACFlB,kBAAkB,GAAGV,MAAM,CAACU,kBAAkB,CAAC;EAE/C,OAAOD,iBAAiB,CAACC,kBAAkB,EAAEC,SAAS,CAAC;AACzD","ignoreList":[]}
@@ -63,15 +63,12 @@ export default class ParagraphTooLongAssessment extends Assessment {
63
63
  /**
64
64
  *
65
65
  * @param paragraphsLength
66
- * @param tooLongParagraphs
67
66
  * @param config
68
- * @param i18n
69
- * @returns {{score: number, body: React.JSX.Element, status: string}}
67
+ * @returns {{score: number, status: string}}
70
68
  */
71
69
  calculateResult({
72
70
  paragraphsLength,
73
- config,
74
- i18n
71
+ config
75
72
  }) {
76
73
  let status = 'bad';
77
74
  if (paragraphsLength.length === 0) {
@@ -113,28 +110,24 @@ export default class ParagraphTooLongAssessment extends Assessment {
113
110
  *
114
111
  * @param {Paper} paper The paper to use for the assessment.
115
112
  * @param {Researcher} researcher The researcher used for calling research.
116
- * @param i18n
117
113
  * @returns {object} The assessment result.
118
114
  */
119
115
  getResult({
120
116
  paper,
121
- researcher,
122
- i18n
117
+ researcher
123
118
  }) {
124
119
  let paragraphsLength = researcher.getResearch('getParagraphLength');
125
120
  paragraphsLength = this.sortParagraphs(paragraphsLength);
126
121
  const config = this.getConfig(researcher);
127
122
  const paragraphLengthResult = this.calculateResult({
128
123
  paragraphsLength,
129
- config,
130
- i18n
124
+ config
131
125
  });
132
126
  const assessmentResult = new AssessmentResult({
133
127
  config: this._config
134
128
  });
135
129
  assessmentResult.setScore(paragraphLengthResult.score);
136
130
  assessmentResult.setStatus(paragraphLengthResult.status);
137
- assessmentResult.setBody(paragraphLengthResult.body);
138
131
  return assessmentResult;
139
132
  }
140
133
 
@@ -1 +1 @@
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,0BAA0B;IAC5C,IAAI,CAACmB,OAAO,GAAGxB,KAAK,CAACS,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEiB,SAASA,CAACC,UAAU,EAAE;IACpB,MAAMC,aAAa,GAAG,IAAI,CAACH,OAAO;IAClC,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A,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
+ {"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","status","length","longestParagraphLength","countLength","score","getScore","sortParagraphs","paragraphs","sort","a","b","getResult","paper","getResearch","paragraphLengthResult","assessmentResult","setScore","setStatus","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 config\n * @returns {{score: number, status: string}}\n */\n calculateResult({paragraphsLength, config}) {\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 * @returns {object} The assessment result.\n */\n getResult({paper, researcher}) {\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 });\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(paragraphLengthResult.score);\n assessmentResult.setStatus(paragraphLengthResult.status);\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,gB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zB;IACF,CAAC,CAAC;IACF,MAAMyC,gBAAgB,GAAG,IAAI9C,gBAAgB,CAAC;MAACK,MAAM,EAAE,IAAI,CAACgB;IAAO,CAAC,CAAC;IAErEyB,gBAAgB,CAACC,QAAQ,CAACF,qBAAqB,CAACV,KAAK,CAAC;IACtDW,gBAAgB,CAACE,SAAS,CAACH,qBAAqB,CAACd,MAAM,CAAC;IAExD,OAAOe,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEG,YAAYA,CAACN,KAAK,EAAE;IAClB,OAAO,IAAI,CAACO,6BAA6B,CAACP,KAAK,CAAC;EAClD;AACF","ignoreList":[]}
@@ -37,10 +37,9 @@ export default class RelatedKeywordsAssessment extends Assessment {
37
37
  *
38
38
  * @param data
39
39
  * @param relatedKeywords
40
- * @param i18n
41
40
  * @returns {{score: number, status: string, words}}
42
41
  */
43
- calculateResult(data, relatedKeywords, i18n) {
42
+ calculateResult(data, relatedKeywords) {
44
43
  const {
45
44
  totalWordUsed,
46
45
  words,
@@ -65,23 +64,21 @@ export default class RelatedKeywordsAssessment extends Assessment {
65
64
  *
66
65
  * @param paper
67
66
  * @param researcher
68
- * @param i18n
69
67
  * @returns {AssessmentResult}
70
68
  */
71
69
  getResult({
72
70
  paper,
73
- researcher,
74
- i18n
71
+ researcher
75
72
  }) {
76
73
  const relatedKeywords = researcher.getResearch('checkRelatedKeywords');
77
74
  const data = paper.getData();
78
- const result = this.calculateResult(data, relatedKeywords, i18n);
75
+ const result = this.calculateResult(data, relatedKeywords);
79
76
  const assessmentResult = new AssessmentResult({
80
77
  config: this._config
81
78
  });
82
79
  assessmentResult.setScore(result.score);
83
80
  assessmentResult.setStatus(result.status);
84
- assessmentResult.setBody(result.words);
81
+ assessmentResult.setData(result.words);
85
82
  return assessmentResult;
86
83
  }
87
84
 
@@ -1 +1 @@
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#related-keywords',\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;;AAE3B;AACA;AACA;AACA,eAAe,MAAMC,yBAAyB,SAASF,UAAU,CAAC;EAChE;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,mBAAmB;MACvBM,WAAW,EAAE,aAAa;MAC1BC,OAAO,EAAE,KAAK;MACdC,MAAM,EACJ,8FAA8F;MAChGC,QAAQ,EAAE,MAAM;MAChBC,KAAK,EAAE,kBAAkB;MACzBC,OAAO,EAAE;QACPC,IAAI,EAAE,sCAAsC;QAC5CC,GAAG,EACD,wFAAwF;QAC1FC,OAAO,EAAE;MACX;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAGf,mBAAmB;IACrC,IAAI,CAACgB,OAAO,GAAGnB,KAAK,CAACO,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEc,eAAeA,CAACC,IAAI,EAAEC,eAAe,E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reList":[]}
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","totalWordUsed","words","isWordUsedExceeding","status","related_keywords","length","score","getScore","getResult","paper","researcher","getResearch","getData","result","assessmentResult","setScore","setStatus","setData","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#related-keywords',\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 * @returns {{score: number, status: string, words}}\n */\n calculateResult(data, relatedKeywords) {\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 * @returns {AssessmentResult}\n */\n getResult({paper, researcher}) {\n const relatedKeywords = researcher.getResearch('checkRelatedKeywords');\n const data = paper.getData();\n\n const result = this.calculateResult(data, relatedKeywords);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(result.score);\n assessmentResult.setStatus(result.status);\n assessmentResult.setData(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;;AAE3B;AACA;AACA;AACA,eAAe,MAAMC,yBAAyB,SAASF,UAAU,CAAC;EAChE;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,mBAAmB;MACvBM,WAAW,EAAE,aAAa;MAC1BC,OAAO,EAAE,KAAK;MACdC,MAAM,EACJ,8FAA8F;MAChGC,QAAQ,EAAE,MAAM;MAChBC,KAAK,EAAE,kBAAkB;MACzBC,OAAO,EAAE;QACPC,IAAI,EAAE,sCAAsC;QAC5CC,GAAG,EACD,wFAAwF;QAC1FC,OAAO,EAAE;MACX;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAGf,mBAAmB;IACrC,IAAI,CAACgB,OAAO,GAAGnB,KAAK,CAACO,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AAC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reList":[]}
@@ -64,10 +64,9 @@ export default class SentenceBeginningsAssessment extends Assessment {
64
64
  /**
65
65
  *
66
66
  * @param groupedSentenceBeginnings
67
- * @param i18n
68
- * @returns {{score: number, body: React.JSX.Element, status: string}}
67
+ * @returns {{score: number, status: string}}
69
68
  */
70
- calculateSentenceBeginningsResult(groupedSentenceBeginnings, i18n) {
69
+ calculateSentenceBeginningsResult(groupedSentenceBeginnings) {
71
70
  let status = '';
72
71
  if (groupedSentenceBeginnings.total > 0) {
73
72
  status = 'bad';
@@ -85,23 +84,22 @@ export default class SentenceBeginningsAssessment extends Assessment {
85
84
  *
86
85
  * @param paper
87
86
  * @param researcher
88
- * @param i18n
89
87
  * @returns {AssessmentResult}
90
88
  */
91
89
  getResult({
92
90
  paper,
93
- researcher,
94
- i18n
91
+ researcher
95
92
  }) {
96
93
  const sentenceBeginnings = researcher.getResearch('getSentenceBeginnings');
94
+ const sentenceBeginningsErrors = sentenceBeginnings.filter(sentenceBeginning => sentenceBeginning.count > maximumConsecutiveDuplicates);
97
95
  const groupedSentenceBeginnings = this.groupSentenceBeginnings(sentenceBeginnings);
98
- const calculatedResult = this.calculateSentenceBeginningsResult(groupedSentenceBeginnings, i18n);
96
+ const calculatedResult = this.calculateSentenceBeginningsResult(groupedSentenceBeginnings);
99
97
  const assessmentResult = new AssessmentResult({
100
98
  config: this._config
101
99
  });
100
+ assessmentResult.setData(sentenceBeginningsErrors);
102
101
  assessmentResult.setScore(calculatedResult.score);
103
102
  assessmentResult.setStatus(calculatedResult.status);
104
- assessmentResult.setBody(calculatedResult.body);
105
103
  return assessmentResult;
106
104
  }
107
105
 
@@ -1 +1 @@
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,gBAAgB;AACvB,OAAOC,UAAU;AACjB,SAAQC,aAAa,QAAO,wBAAwB;AACpD,SAAQC,sBAAsB;AAE9B,MAAMC,4BAA4B,GAAG,CAAC;;AAEtC;AACA;AACA;AACA,eAAe,MAAMC,4BAA4B,SAASJ,UAAU,CAAC;EACnE;AACF;AACA;AACA;AACA;AACA;AACA;EACEK,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAA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CM,MAAM,GAAG,KAAK;IAChB,CAAC,MAAM;MACLA,MAAM,GAAG,MAAM;IACjB;IAEA,MAAMC,KAAK,GAAG,IAAI,CAACC,QAAQ,CAAC,IAAI,CAACf,OAAO,CAACX,QAAQ,EAAEwB,MAAM,CAAC;IAE1D,OAAO;MACLC,KAAK;MACLD;IACF,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEG,SAASA,CAAC;IAACC,KAAK;IAAEC,UAAU;IAAEN;EAAI,CAAC,EAAE;IACnC,MAAMV,kBAAkB,GAAGgB,UAAU,CAACC,WAAW,CAAC,uBAAuB,CAAC;IAC1E,MAAMR,yBAAyB,GAAG,IAAI,CAACV,uBAAuB,CAACC,kBAAkB,CAAC;IAClF,MAAMkB,gBAAgB,GAAG,IAAI,CAACV,iCAAiC,CAC7DC,yBAAyB,EACzBC,IACF,CAAC;IACD,MAAMS,gBAAgB,GAAG,IAAI1C,gBAAgB,CAAC;MAACO,MAAM,EAAE,IAAI,CAACc;IAAO,CAAC,CAAC;IAErEqB,gBAAgB,CAACC,QAAQ,CAACF,gBAAgB,CAACN,KAAK,CAAC;IACjDO,gBAAgB,CAACE,SAAS,CAACH,gBAAgB,CAACP,MAAM,CAAC;IACnDQ,gBAAgB,CAACG,OAAO,CAACJ,gBAAgB,CAACK,IAAI,CAAC;IAE/C,OAAOJ,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEK,YAAYA,CAACT,KAAK,EAAEC,UAAU,EAAE;IAC9B,OACE,IAAI,CAACS,6BAA6B,CAACV,KAAK,CAAC,IAAIC,UAAU,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","status","score","getScore","getResult","paper","researcher","getResearch","sentenceBeginningsErrors","filter","sentenceBeginning","calculatedResult","assessmentResult","setData","setScore","setStatus","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 * @returns {{score: number, status: string}}\n */\n calculateSentenceBeginningsResult(groupedSentenceBeginnings) {\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 * @returns {AssessmentResult}\n */\n getResult({paper, researcher}) {\n const sentenceBeginnings = researcher.getResearch('getSentenceBeginnings');\n const sentenceBeginningsErrors = sentenceBeginnings.filter(\n sentenceBeginning => sentenceBeginning.count > maximumConsecutiveDuplicates\n );\n\n const groupedSentenceBeginnings = this.groupSentenceBeginnings(sentenceBeginnings);\n const calculatedResult = this.calculateSentenceBeginningsResult(groupedSentenceBeginnings);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setData(sentenceBeginningsErrors);\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\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,OAAOC,UAAU;AACjB,SAAQC,aAAa,QAAO,wBAAwB;AACpD,SAAQC,sBAAsB;AAE9B,MAAMC,4BAA4B,GAAG,CAAC;;AAEtC;AACA;AACA;AACA,eAAe,MAAMC,4BAA4B,SAASJ,UAAU,CA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,23 @@ class SentenceLengthInTextAssessment extends Assessment {
47
47
  * @param {Paper} paper The paper to use for the assessment.
48
48
  * @param {Researcher} researcher The researcher used for calling research.
49
49
  *
50
- * @param i18n
51
50
  * @returns {AssessmentResult} The Assessment result.
52
51
  */
53
52
  getResult({
54
53
  paper,
55
- researcher,
56
- i18n
54
+ researcher
57
55
  }) {
58
56
  const sentences = researcher.getResearch('countSentencesFromText');
59
57
  if (researcher.getConfig('sentenceLength')) {
60
58
  this._config = this.getLanguageSpecificConfig(researcher);
61
59
  }
62
60
  const percentage = this.calculatePercentage(sentences);
63
- const result = this.calculateResult(percentage, i18n);
61
+ const result = this.calculateResult(percentage);
64
62
  const assessmentResult = new AssessmentResult({
65
63
  config: this._config
66
64
  });
67
65
  assessmentResult.setScore(result.score);
68
66
  assessmentResult.setStatus(result.status);
69
- assessmentResult.setBody(result.body);
70
67
  return assessmentResult;
71
68
  }
72
69
 
@@ -115,10 +112,9 @@ class SentenceLengthInTextAssessment extends Assessment {
115
112
  /**
116
113
  *
117
114
  * @param percentage
118
- * @param i18n
119
- * @returns {{score: number, body: React.JSX.Element, status: string}}
115
+ * @returns {{score: number, status: string}}
120
116
  */
121
- calculateResult(percentage, i18n) {
117
+ calculateResult(percentage) {
122
118
  let status = '';
123
119
  if (percentage <= this._config.recommendedLength) {
124
120
  status = 'good';
@@ -1 +1 @@
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,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,GAAG3B,KAAK,CAACY,aAAa,EAAEH,MAAM,CAAC;IAC3C,IAAI,CAACmB,UAAU,GAAGtB,uBAAuB;EAC3C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE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,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","sentences","getResearch","getConfig","getLanguageSpecificConfig","percentage","calculatePercentage","result","calculateResult","assessmentResult","setScore","score","setStatus","status","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 * @returns {AssessmentResult} The Assessment result.\n */\n getResult({paper, researcher}) {\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);\n\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(result.score);\n assessmentResult.setStatus(result.status);\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 * @returns {{score: number, status: string}}\n */\n calculateResult(percentage) {\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,E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AACA;EACE1C,mBAAmBA,CAAC8B,SAAS,EAAE;IAC7B,OAAO9B,mBAAmB,CAAC8B,SAAS,EAAE,IAAI,CAACL,OAAO,CAACR,iBAAiB,CAAC;EACvE;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEiC,qBAAqBA,CAACpB,SAAS,EAAE;IAC/B,OAAO,IAAI,CAAC9B,mBAAmB,CAAC8B,SAAS,CAAC,CAACkB,MAAM;EACnD;AACF;AAEA,eAAe3C,8BAA8B","ignoreList":[]}
@@ -78,10 +78,9 @@ export default class TransitionWordsAssessment extends Assessment {
78
78
  /**
79
79
  *
80
80
  * @param transitionWordSentences
81
- * @param i18n
82
- * @returns {{score: number, body: React.JSX.Element, status: string}}
81
+ * @returns {{score: number, status: string}}
83
82
  */
84
- calculateTransitionWordResult(transitionWordSentences, i18n) {
83
+ calculateTransitionWordResult(transitionWordSentences) {
85
84
  const percentage = this.calculateTransitionWordPercentage(transitionWordSentences);
86
85
  const score = this.calculateScoreFromPercentage(percentage);
87
86
  let status = 'good';
@@ -99,22 +98,19 @@ export default class TransitionWordsAssessment extends Assessment {
99
98
  *
100
99
  * @param paper
101
100
  * @param researcher
102
- * @param i18n
103
101
  * @returns {AssessmentResult}
104
102
  */
105
103
  getResult({
106
104
  paper,
107
- researcher,
108
- i18n
105
+ researcher
109
106
  }) {
110
107
  const transitionWordSentences = researcher.getResearch('findTransitionWords');
111
- const transitionWordResult = this.calculateTransitionWordResult(transitionWordSentences, i18n);
108
+ const transitionWordResult = this.calculateTransitionWordResult(transitionWordSentences);
112
109
  const assessmentResult = new AssessmentResult({
113
110
  config: this._config
114
111
  });
115
112
  assessmentResult.setScore(transitionWordResult.score);
116
113
  assessmentResult.setStatus(transitionWordResult.status);
117
- assessmentResult.setBody(transitionWordResult.body);
118
114
  return assessmentResult;
119
115
  }
120
116
 
@@ -1 +1 @@
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,GAAG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AU,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","score","status","customScore","getScore","getResult","paper","researcher","getResearch","transitionWordResult","assessmentResult","setScore","setStatus","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 * @returns {{score: number, status: string}}\n */\n calculateTransitionWordResult(transitionWordSentences) {\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 * @returns {AssessmentResult}\n */\n getResult({paper, researcher}) {\n const transitionWordSentences = researcher.getResearch('findTransitionWords');\n const transitionWordResult = this.calculateTransitionWordResult(transitionWordSentences);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(transitionWordResult.score);\n assessmentResult.setStatus(transitionWordResult.status);\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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]}
@@ -39,24 +39,20 @@ export default class TextImagesAssessment extends Assessment {
39
39
  *
40
40
  * @param {Paper} paper The Paper object to assess.
41
41
  * @param {Researcher} researcher The Researcher object containing all available researches.
42
- *
43
- * @param i18n
44
42
  * @returns {AssessmentResult} The result of the assessment, containing both a score and a descriptive text.
45
43
  */
46
44
  getResult({
47
45
  paper,
48
- researcher,
49
- i18n
46
+ researcher
50
47
  }) {
51
48
  this.imageCount = researcher.getResearch('imageCount');
52
49
  this.videoCount = researcher.getResearch('videoCount');
53
50
  const assessmentResult = new AssessmentResult({
54
51
  config: this._config
55
52
  });
56
- const calculatedResult = this.calculateResult(i18n);
53
+ const calculatedResult = this.calculateResult();
57
54
  assessmentResult.setScore(calculatedResult.score);
58
55
  assessmentResult.setStatus(calculatedResult.status);
59
- assessmentResult.setBody(calculatedResult.body);
60
56
  return assessmentResult;
61
57
  }
62
58
 
@@ -72,11 +68,10 @@ export default class TextImagesAssessment extends Assessment {
72
68
  }
73
69
 
74
70
  /**
75
- * Calculate the result based on the availability of images in the text, including videos in product pages.
76
71
  *
77
- * @returns {Object} The calculated result.
72
+ * @returns {{score: number, status: string}}
78
73
  */
79
- calculateResult(i18n) {
74
+ calculateResult() {
80
75
  // If "countVideos" is on, we include videos in the assessment
81
76
  const mediaCount = this._countVideos ? this.imageCount + this.videoCount : this.imageCount;
82
77
  let status = '';
@@ -1 +1 @@
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,QAAQ;MACZO,MAAM,EACJ,+FAA+F;MACjGC,QAAQ,EAAE,MAAM;MAChBC,WAAW,EAAE,aAAa;MAC1BC,KAAK,EAAE,OAAO;MACdC,OAAO,EAAE;QACPC,IAAI,EAAE,6BAA6B;QACnCC,OAAO,EAAE,EAAE;QACXC,GAAG,EAAE;MACP;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAGf,QAAQ;IAC1B,IAAI,CAACgB,OAAO,GAAGnB,KAAK,CAACQ,aAAa,EAAEF,MAAM,CAAC;IAC3C,IAAI,CAACc,YAAY,GAAGb,WAAW;EACjC;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEc,SAASA,CAAC;IAACC,KAAK;IAAEC,UAAU;IAAEC;EAAI,CAAC,EAAE;IACnC,IAAI,CAACC,UAAU,GAAGF,UAAU,CAACG,WAAW,CAAC,YAAY,CAAC;IACtD,IAAI,CAACC,UAAU,GAAGJ,UAAU,CAACG,WAAW,CAAC,YAAY,CAAC;IAEtD,MAAME,gBAAgB,GAAG,IAAI1B,gBAAgB,CAAC;MAACI,MAAM,EAAE,IAAI,CAACa;IAAO,CAAC,CAAC;IAErE,MAAMU,gBAAgB,GAAG,IAAI,CAACC,eAAe,CAACN,IAAI,CAAC;IAEnDI,gBAAgB,CAACG,QAAQ,CAACF,gBAAgB,CAACG,KAAK,CAAC;IACjDJ,gBAAgB,CAACK,SAAS,CAACJ,gBAAgB,CAACK,MAAM,CAAC;IACnDN,gBAAgB,CAACO,OAAO,CAACN,gBAAgB,CAACO,IAAI,CAAC;IAE/C,OAAOR,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACES,YAAYA,CAACf,KAAK,EAAE;IAClB,OAAOA,KAAK,CAACgB,OAAO,CAAC,CAAC;EACxB;;EAEA;AACF;AACA;AACA;AACA;EACER,eAAeA,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","imageCount","getResearch","videoCount","assessmentResult","calculatedResult","calculateResult","setScore","score","setStatus","status","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 * @returns {AssessmentResult} The result of the assessment, containing both a score and a descriptive text.\n */\n getResult({paper, researcher}) {\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();\n\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\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 *\n * @returns {{score: number, status: string}}\n */\n calculateResult() {\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,eAA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