axyseo 2.0.0-alpha.0.0.40 → 2.0.0-alpha.0.0.42

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 (23) hide show
  1. package/build/languageProcessing/helpers/match/findKeywordFormsInString.js +5 -5
  2. package/build/languageProcessing/helpers/match/findKeywordFormsInString.js.map +1 -1
  3. package/build/languageProcessing/helpers/match/matchWordFormsWithSentence.js +1 -2
  4. package/build/languageProcessing/helpers/match/matchWordFormsWithSentence.js.map +1 -1
  5. package/build/languageProcessing/researches/findKeywordInFirstParagraph.js +7 -7
  6. package/build/languageProcessing/researches/findKeywordInFirstParagraph.js.map +1 -1
  7. package/build/languageProcessing/researches/getKeywordDensity.js +5 -5
  8. package/build/languageProcessing/researches/getKeywordDensity.js.map +1 -1
  9. package/build/languageProcessing/researches/keywordCount.js +10 -11
  10. package/build/languageProcessing/researches/keywordCount.js.map +1 -1
  11. package/build/scoring/assessments/readability/ParagraphTooLongAssessment.js +12 -11
  12. package/build/scoring/assessments/readability/ParagraphTooLongAssessment.js.map +1 -1
  13. package/build/scoring/assessments/seo/IntroductionKeywordAssessment.js +2 -2
  14. package/build/scoring/assessments/seo/IntroductionKeywordAssessment.js.map +1 -1
  15. package/build/scoring/assessments/seo/KeywordDensityAssessment.js +0 -1
  16. package/build/scoring/assessments/seo/KeywordDensityAssessment.js.map +1 -1
  17. package/build/scoring/assessments/seo/MetaDescriptionKeywordAssessment.js +2 -6
  18. package/build/scoring/assessments/seo/MetaDescriptionKeywordAssessment.js.map +1 -1
  19. package/build/scoring/assessments/seo/MetaTitleKeywordAssessment.js +15 -12
  20. package/build/scoring/assessments/seo/MetaTitleKeywordAssessment.js.map +1 -1
  21. package/build/scoring/assessments/seo/SchemaAssessment.js +1 -1
  22. package/build/scoring/assessments/seo/SchemaAssessment.js.map +1 -1
  23. package/package.json +5 -3
@@ -1,4 +1,4 @@
1
- import { isEmpty, sum } from "lodash";
1
+ import { isEmpty, sum } from 'lodash';
2
2
  import matchTextWithArray from "./matchTextWithArray.js";
3
3
 
4
4
  /**
@@ -61,8 +61,8 @@ const findWordFormsInString = function (keywordForms, text, locale, matchWordCus
61
61
  */
62
62
  const findTopicFormsInString = function (topicForms, text, useSynonyms, locale, matchWordCustomHelper) {
63
63
  // First check if the keyword is found in the text
64
- let result = findWordFormsInString(topicForms.keyphraseForms, text, locale, matchWordCustomHelper);
65
- result.keyphraseOrSynonym = "keyphrase";
64
+ let result = findWordFormsInString(topicForms.keyphraseForms, text.toLowerCase(), locale, matchWordCustomHelper);
65
+ result.keyphraseOrSynonym = 'keyphrase';
66
66
 
67
67
  // If a full match found with the keyword or if no synonyms are supplied or supposed to be used, return the keyphrase search result.
68
68
  if (result.percentWordMatches === 100 || useSynonyms === false || isEmpty(topicForms.synonymsForms)) {
@@ -73,7 +73,7 @@ const findTopicFormsInString = function (topicForms, text, useSynonyms, locale,
73
73
  const resultsSynonyms = [];
74
74
  for (let i = 0; i < topicForms.synonymsForms.length; i++) {
75
75
  const synonym = topicForms.synonymsForms[i];
76
- resultsSynonyms[i] = findWordFormsInString(synonym, text, locale, matchWordCustomHelper);
76
+ resultsSynonyms[i] = findWordFormsInString(synonym, text.toLowerCase(), locale, matchWordCustomHelper);
77
77
  }
78
78
 
79
79
  // Find which synonym occurred most fully.
@@ -87,7 +87,7 @@ const findTopicFormsInString = function (topicForms, text, useSynonyms, locale,
87
87
 
88
88
  // If the best synonym showed better results than the keyword, return the synonym.
89
89
  result = resultsSynonyms[bestSynonymIndex];
90
- result.keyphraseOrSynonym = "synonym";
90
+ result.keyphraseOrSynonym = 'synonym';
91
91
  return result;
92
92
  };
93
93
  export { findWordFormsInString, findTopicFormsInString };
@@ -1 +1 @@
1
- {"version":3,"file":"findKeywordFormsInString.js","names":["isEmpty","sum","matchTextWithArray","findWordFormsInString","keywordForms","text","locale","matchWordCustomHelper","wordNumber","length","foundWords","Array","positions","matches","i","matchedKeyphrase","count","push","position","concat","foundNumberOfWords","result","countWordMatches","percentWordMatches","Math","round","filter","min","findTopicFormsInString","topicForms","useSynonyms","keyphraseForms","keyphraseOrSynonym","synonymsForms","resultsSynonyms","synonym","foundSynonyms","map","resultSynonyms","bestSynonymIndex","indexOf","max"],"sources":["../../../../src/languageProcessing/helpers/match/findKeywordFormsInString.js"],"sourcesContent":["import { isEmpty, sum } from \"lodash\";\nimport matchTextWithArray from \"./matchTextWithArray.js\";\n\n/**\n * Matches forms of words in the keyphrase against a given text.\n *\n * @param {Array} keywordForms The array with word forms of all (content) words from the keyphrase in a shape\n * [ [ form1, form2, ... ], [ form1, form2, ... ] ].\n * @param {string} text The string to match the word forms against.\n * @param {string} locale The locale of the paper.\n * @param {function} matchWordCustomHelper The helper function to match word in text.\n *\n * @returns {Object} The number and the percentage of the keyphrase words that were matched in the text by at least one form,\n * and the lowest number of positions of the matches.\n */\nconst findWordFormsInString = function( keywordForms, text, locale, matchWordCustomHelper ) {\n\tconst wordNumber = keywordForms.length;\n\tconst foundWords = Array( wordNumber );\n\tlet positions = [];\n\tlet matches = [];\n\n\tfor ( let i = 0; i < wordNumber; i++ ) {\n\t\tconst matchedKeyphrase = matchTextWithArray( text, keywordForms[ i ], locale, matchWordCustomHelper );\n\t\tfoundWords[ i ] = matchedKeyphrase.count > 0 ? 1 : 0;\n\t\tpositions.push( matchedKeyphrase.position );\n\t\tmatches = matches.concat( matchedKeyphrase.matches );\n\t}\n\tconst foundNumberOfWords = sum( foundWords );\n\tconst result = {\n\t\tcountWordMatches: foundNumberOfWords,\n\t\tpercentWordMatches: 0,\n\t\tmatches: matches,\n\t};\n\n\tif ( wordNumber > 0 ) {\n\t\tresult.percentWordMatches = Math.round( foundNumberOfWords / wordNumber * 100 );\n\t}\n\t// Filtered out negative number, i.e. -1.\n\tpositions = positions.filter( position => position >= 0 );\n\tresult.position = positions.length === 0 ? -1 : Math.min( ...positions );\n\n\treturn result;\n};\n\n/**\n * Matches forms of words in the keyphrase and in the synonyms against a given text.\n *\n * @param {Object} topicForms The object with word forms of all (content) words from the keyphrase and eventually synonyms,\n * comes in a shape {\n * keyphraseForms: [[ form1, form2, ... ], [ form1, form2, ... ]],\n * synonymsForms: [\n * [[ form1, form2, ... ], [ form1, form2, ... ]],\n * [[ form1, form2, ... ], [ form1, form2, ... ]],\n * [[ form1, form2, ... ], [ form1, form2, ... ]],\n * ],\n * }\n * @param {string} text The string to match the word forms against.\n * @param {boolean} useSynonyms Whether to use synonyms as if it was keyphrase or not (depends on the assessment).\n * @param {string} locale The locale of the paper.\n * @param {function} matchWordCustomHelper The language-specific helper function to match word in text.\n *\n * @returns {Object} The number and the percentage for the keyphrase words or synonyms that were matched in the text by at least one form,\n * and whether the keyphrase or a synonym was matched.\n */\nconst findTopicFormsInString = function( topicForms, text, useSynonyms, locale, matchWordCustomHelper ) {\n\t// First check if the keyword is found in the text\n\tlet result = findWordFormsInString( topicForms.keyphraseForms, text, locale, matchWordCustomHelper );\n\tresult.keyphraseOrSynonym = \"keyphrase\";\n\n\t// If a full match found with the keyword or if no synonyms are supplied or supposed to be used, return the keyphrase search result.\n\tif ( result.percentWordMatches === 100 || useSynonyms === false || isEmpty( topicForms.synonymsForms ) ) {\n\t\treturn result;\n\t}\n\n\t// Collect results of matching of every synonym with the text.\n\tconst resultsSynonyms = [];\n\tfor ( let i = 0; i < topicForms.synonymsForms.length; i++ ) {\n\t\tconst synonym = topicForms.synonymsForms[ i ];\n\t\tresultsSynonyms[ i ] = findWordFormsInString( synonym, text, locale, matchWordCustomHelper );\n\t}\n\n\t// Find which synonym occurred most fully.\n\tconst foundSynonyms = resultsSynonyms.map( resultSynonyms => resultSynonyms.percentWordMatches );\n\tconst bestSynonymIndex = foundSynonyms.indexOf( Math.max( ...foundSynonyms ) );\n\n\t// If the best synonym showed lower results than the keyword, return the keyword.\n\tif ( result.percentWordMatches >= resultsSynonyms[ bestSynonymIndex ].percentWordMatches ) {\n\t\treturn result;\n\t}\n\n\t// If the best synonym showed better results than the keyword, return the synonym.\n\tresult = resultsSynonyms[ bestSynonymIndex ];\n\tresult.keyphraseOrSynonym = \"synonym\";\n\n\treturn result;\n};\n\nexport {\n\tfindWordFormsInString,\n\tfindTopicFormsInString,\n};\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,GAAG,QAAQ,QAAQ;AACrC,OAAOC,kBAAkB;;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,qBAAqB,GAAG,SAAAA,CAAUC,YAAY,EAAEC,IAAI,EAAEC,MAAM,EAAEC,qBAAqB,EAAG;EAC3F,MAAMC,UAAU,GAAGJ,YAAY,CAACK,MAAM;EACtC,MAAMC,UAAU,GAAGC,KAAK,CAAEH,UAAW,CAAC;EACtC,IAAII,SAAS,GAAG,EAAE;EAClB,IAAIC,OAAO,GAAG,EAAE;EAEhB,KAAM,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,UAAU,EAAEM,CAAC,EAAE,EAAG;IACtC,MAAMC,gBAAgB,GAAGb,kBAAkB,CAAEG,IAAI,EAAED,YAAY,CAAEU,CAAC,CAAE,EAAER,MAAM,EAAEC,qBAAsB,CAAC;IACrGG,UAAU,CAAEI,CAAC,CAAE,GAAGC,gBAAgB,CAACC,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;IACpDJ,SAAS,CAACK,IAAI,CAAEF,gBAAgB,CAACG,QAAS,CAAC;IAC3CL,OAAO,GAAGA,OAAO,CAACM,MAAM,CAAEJ,gBAAgB,CAACF,OAAQ,CAAC;EACrD;EACA,MAAMO,kBAAkB,GAAGnB,GAAG,CAAES,UAAW,CAAC;EAC5C,MAAMW,MAAM,GAAG;IACdC,gBAAgB,EAAEF,kBAAkB;IACpCG,kBAAkB,EAAE,CAAC;IACrBV,OAAO,EAAEA;EACV,CAAC;EAED,IAAKL,UAAU,GAAG,CAAC,EAAG;IACrBa,MAAM,CAACE,kBAAkB,GAAGC,IAAI,CAACC,KAAK,CAAEL,kBAA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c,CAACf,kBAAmB,CAAC;EAChG,MAAMgB,gBAAgB,GAAGH,aAAa,CAACI,OAAO,CAAEhB,IAAI,CAACiB,GAAG,CAAE,GAAGL,aAAc,CAAE,CAAC;;EAE9E;EACA,IAAKf,MAAM,CAACE,kBAAkB,IAAIW,eAAe,CAAEK,gBAAgB,CAAE,CAAChB,kBAAkB,EAAG;IAC1F,OAAOF,MAAM;EACd;;EAEA;EACAA,MAAM,GAAGa,eAAe,CAAEK,gBAAgB,CAAE;EAC5ClB,MAAM,CAACW,kBAAkB,GAAG,SAAS;EAErC,OAAOX,MAAM;AACd,CAAC;AAED,SACClB,qBAAqB,EACrByB,sBAAsB","ignoreList":[]}
1
+ {"version":3,"file":"findKeywordFormsInString.js","names":["isEmpty","sum","matchTextWithArray","findWordFormsInString","keywordForms","text","locale","matchWordCustomHelper","wordNumber","length","foundWords","Array","positions","matches","i","matchedKeyphrase","count","push","position","concat","foundNumberOfWords","result","countWordMatches","percentWordMatches","Math","round","filter","min","findTopicFormsInString","topicForms","useSynonyms","keyphraseForms","toLowerCase","keyphraseOrSynonym","synonymsForms","resultsSynonyms","synonym","foundSynonyms","map","resultSynonyms","bestSynonymIndex","indexOf","max"],"sources":["../../../../src/languageProcessing/helpers/match/findKeywordFormsInString.js"],"sourcesContent":["import {isEmpty, sum} from 'lodash';\nimport matchTextWithArray from './matchTextWithArray.js';\n\n/**\n * Matches forms of words in the keyphrase against a given text.\n *\n * @param {Array} keywordForms The array with word forms of all (content) words from the keyphrase in a shape\n * [ [ form1, form2, ... ], [ form1, form2, ... ] ].\n * @param {string} text The string to match the word forms against.\n * @param {string} locale The locale of the paper.\n * @param {function} matchWordCustomHelper The helper function to match word in text.\n *\n * @returns {Object} The number and the percentage of the keyphrase words that were matched in the text by at least one form,\n * and the lowest number of positions of the matches.\n */\nconst findWordFormsInString = function(keywordForms, text, locale, matchWordCustomHelper) {\n const wordNumber = keywordForms.length;\n const foundWords = Array(wordNumber);\n let positions = [];\n let matches = [];\n\n for (let i = 0; i < wordNumber; i++) {\n const matchedKeyphrase = matchTextWithArray(\n text,\n keywordForms[i],\n locale,\n matchWordCustomHelper\n );\n foundWords[i] = matchedKeyphrase.count > 0 ? 1 : 0;\n positions.push(matchedKeyphrase.position);\n matches = matches.concat(matchedKeyphrase.matches);\n }\n const foundNumberOfWords = sum(foundWords);\n const result = {\n countWordMatches: foundNumberOfWords,\n percentWordMatches: 0,\n matches: matches\n };\n\n if (wordNumber > 0) {\n result.percentWordMatches = Math.round((foundNumberOfWords / wordNumber) * 100);\n }\n // Filtered out negative number, i.e. -1.\n positions = positions.filter(position => position >= 0);\n result.position = positions.length === 0 ? -1 : Math.min(...positions);\n\n return result;\n};\n\n/**\n * Matches forms of words in the keyphrase and in the synonyms against a given text.\n *\n * @param {Object} topicForms The object with word forms of all (content) words from the keyphrase and eventually synonyms,\n * comes in a shape {\n * keyphraseForms: [[ form1, form2, ... ], [ form1, form2, ... ]],\n * synonymsForms: [\n * [[ form1, form2, ... ], [ form1, form2, ... ]],\n * [[ form1, form2, ... ], [ form1, form2, ... ]],\n * [[ form1, form2, ... ], [ form1, form2, ... ]],\n * ],\n * }\n * @param {string} text The string to match the word forms against.\n * @param {boolean} useSynonyms Whether to use synonyms as if it was keyphrase or not (depends on the assessment).\n * @param {string} locale The locale of the paper.\n * @param {function} matchWordCustomHelper The language-specific helper function to match word in text.\n *\n * @returns {Object} The number and the percentage for the keyphrase words or synonyms that were matched in the text by at least one form,\n * and whether the keyphrase or a synonym was matched.\n */\nconst findTopicFormsInString = function(\n topicForms,\n text,\n useSynonyms,\n locale,\n matchWordCustomHelper\n) {\n // First check if the keyword is found in the text\n let result = findWordFormsInString(\n topicForms.keyphraseForms,\n text.toLowerCase(),\n locale,\n matchWordCustomHelper\n );\n result.keyphraseOrSynonym = 'keyphrase';\n\n // If a full match found with the keyword or if no synonyms are supplied or supposed to be used, return the keyphrase search result.\n if (\n result.percentWordMatches === 100 ||\n useSynonyms === false ||\n isEmpty(topicForms.synonymsForms)\n ) {\n return result;\n }\n\n // Collect results of matching of every synonym with the text.\n const resultsSynonyms = [];\n for (let i = 0; i < topicForms.synonymsForms.length; i++) {\n const synonym = topicForms.synonymsForms[i];\n resultsSynonyms[i] = findWordFormsInString(\n synonym,\n text.toLowerCase(),\n locale,\n matchWordCustomHelper\n );\n }\n\n // Find which synonym occurred most fully.\n const foundSynonyms = resultsSynonyms.map(resultSynonyms => resultSynonyms.percentWordMatches);\n const bestSynonymIndex = foundSynonyms.indexOf(Math.max(...foundSynonyms));\n\n // If the best synonym showed lower results than the keyword, return the keyword.\n if (result.percentWordMatches >= resultsSynonyms[bestSynonymIndex].percentWordMatches) {\n return result;\n }\n\n // If the best synonym showed better results than the keyword, return the synonym.\n result = resultsSynonyms[bestSynonymIndex];\n result.keyphraseOrSynonym = 'synonym';\n\n return result;\n};\n\nexport {findWordFormsInString, findTopicFormsInString};\n"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,GAAG,QAAO,QAAQ;AACnC,OAAOC,kBAAkB;;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,qBAAqB,GAAG,SAAAA,CAASC,YAAY,EAAEC,IAAI,EAAEC,MAAM,EAAEC,qBAAqB,EAAE;EACxF,MAAMC,UAAU,GAAGJ,YAAY,CAACK,MAAM;EACtC,MAAMC,UAAU,GAAGC,KAAK,CAACH,UAAU,CAAC;EACpC,IAAII,SAAS,GAAG,EAAE;EAClB,IAAIC,OAAO,GAAG,EAAE;EAEhB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,UAAU,EAAEM,CAAC,EAAE,EAAE;IACnC,MAAMC,gBAAgB,GAAGb,kBAAkB,CACzCG,IAAI,EACJD,YAAY,CAACU,CAAC,CAAC,EACfR,MAAM,EACNC,qBACF,CAAC;IACDG,UAAU,CAACI,CAAC,CAAC,GAAGC,gBAAgB,CAACC,KAAK,GAAG,CAAC,GAAG,CAAC,GAA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AOb,MAAM;EACf;;EAEA;EACA,MAAMc,eAAe,GAAG,EAAE;EAC1B,KAAK,IAAIrB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGe,UAAU,CAACK,aAAa,CAACzB,MAAM,EAAEK,CAAC,EAAE,EAAE;IACxD,MAAMsB,OAAO,GAAGP,UAAU,CAACK,aAAa,CAACpB,CAAC,CAAC;IAC3CqB,eAAe,CAACrB,CAAC,CAAC,GAAGX,qBAAqB,CACxCiC,OAAO,EACP/B,IAAI,CAAC2B,WAAW,CAAC,CAAC,EAClB1B,MAAM,EACNC,qBACF,CAAC;EACH;;EAEA;EACA,MAAM8B,aAAa,GAAGF,eAAe,CAACG,GAAG,CAACC,cAAc,IAAIA,cAAc,CAAChB,kBAAkB,CAAC;EAC9F,MAAMiB,gBAAgB,GAAGH,aAAa,CAACI,OAAO,CAACjB,IAAI,CAACkB,GAAG,CAAC,GAAGL,aAAa,CAAC,CAAC;;EAE1E;EACA,IAAIhB,MAAM,CAACE,kBAAkB,IAAIY,eAAe,CAACK,gBAAgB,CAAC,CAACjB,kBAAkB,EAAE;IACrF,OAAOF,MAAM;EACf;;EAEA;EACAA,MAAM,GAAGc,eAAe,CAACK,gBAAgB,CAAC;EAC1CnB,MAAM,CAACY,kBAAkB,GAAG,SAAS;EAErC,OAAOZ,MAAM;AACf,CAAC;AAED,SAAQlB,qBAAqB,EAAEyB,sBAAsB","ignoreList":[]}
@@ -42,7 +42,6 @@ const findExactMatchKeyphraseInSentence = (sentence, wordForms, locale, customSp
42
42
  // Initialize the index of the word token of the sentence.
43
43
  let indexOfWordInSentence = 0;
44
44
  let currentMatch = [];
45
-
46
45
  // Check if the tokenized word forms occur in the same order in the sentence tokens.
47
46
  while (indexOfWordInSentence < sentenceTokens.length) {
48
47
  // If the current sentence token matches the current word token of the keyphrase, add it to the current match.
@@ -89,7 +88,7 @@ const findExactMatchKeyphraseInSentence = (sentence, wordForms, locale, customSp
89
88
  const matchWordFormInTokens = (tokens, wordForm, locale) => {
90
89
  let matches = [];
91
90
  tokens.forEach(token => {
92
- const occurrence = matchTextWithTransliteration(token.text, wordForm, locale);
91
+ const occurrence = matchTextWithTransliteration(token.text.toLowerCase(), wordForm, locale);
93
92
  if (occurrence.length > 0) {
94
93
  matches = matches.concat(token);
95
94
  }
@@ -1 +1 @@
1
- {"version":3,"file":"matchWordFormsWithSentence.js","names":["matchTextWithTransliteration","splitIntoTokens","tokenizeKeyphraseFormsForExactMatching","wordForms","customSplitIntoTokensHelper","wordFormText","findExactMatchKeyphraseInSentence","sentence","locale","result","count","matches","keyphraseTokens","sentenceTokens","tokens","indexOfWordInKeyphrase","indexOfWordInSentence","currentMatch","length","sentenceTokenText","text","keyphraseTokenText","foundMatches","toLowerCase","push","matchWordFormInTokens","wordForm","forEach","token","occurrence","concat","matchWordFormsInSentence","matchWordCustomHelper","occurrences","slice","matchWordFormsWithSentence","useExactMatching"],"sources":["../../../../src/languageProcessing/helpers/match/matchWordFormsWithSentence.js"],"sourcesContent":["import matchTextWithTransliteration from \"./matchTextWithTransliteration\";\nimport splitIntoTokens from \"../word/splitIntoTokens\";\n\n/**\n * Tokenizes the word form of the keyphrase for exact matching. This function gets the word form and tokenizes it.\n * This function assumes that if a keyphrase needs to be matched exactly, there will be only one word form.\n * This is the result of how the focus keyphrase is processed in buildTopicStems.js in the buildStems function.\n *\n * @param {(string[])} wordForms \t\t\t\t\tThe word forms to tokenize.\n * @param {function}\tcustomSplitIntoTokensHelper\tA custom helper to split sentences into tokens.\n *\n * @returns {string[]} The tokenized word forms.\n */\nexport const tokenizeKeyphraseFormsForExactMatching = ( wordForms, customSplitIntoTokensHelper ) => {\n\t// Tokenize word form of the keyphrase.\n\tconst wordFormText = wordForms[ 0 ];\n\n\treturn customSplitIntoTokensHelper ? customSplitIntoTokensHelper( wordFormText ) : splitIntoTokens( wordFormText );\n};\n\n/**\n * Gets the exact matches of the keyphrase.\n * Exact matching happens when the user puts the keyphrase in double quotes.\n *\n * @param {Sentence}\tsentence\t\t\t\t\tThe sentence to match the word forms with.\n * @param {string[]}\twordForms\t\t\t\t\tThe word forms to match.\n * @param {string}\t\tlocale\t\t\t\t\t\tThe locale used in the analysis.\n * @param {function}\tcustomSplitIntoTokensHelper\tA custom helper to split sentences into tokens.\n *\n * @returns {{count: number, matches: Token[]}} Object containing the number of the exact matches and the matched tokens.\n */\nconst findExactMatchKeyphraseInSentence = ( sentence, wordForms, locale, customSplitIntoTokensHelper ) => {\n\tconst result = {\n\t\tcount: 0,\n\t\tmatches: [],\n\t};\n\t// Tokenize word forms of the keyphrase.\n\tconst keyphraseTokens = tokenizeKeyphraseFormsForExactMatching( wordForms, customSplitIntoTokensHelper );\n\n\tconst sentenceTokens = sentence.tokens;\n\n\t// Initialize the index of the word token of the keyphrase.\n\tlet indexOfWordInKeyphrase = 0;\n\t// Initialize the index of the word token of the sentence.\n\tlet indexOfWordInSentence = 0;\n\tlet currentMatch = [];\n\n\t// Check if the tokenized word forms occur in the same order in the sentence tokens.\n\twhile ( indexOfWordInSentence < sentenceTokens.length ) {\n\t\t// If the current sentence token matches the current word token of the keyphrase, add it to the current match.\n\t\tconst sentenceTokenText = sentenceTokens[ indexOfWordInSentence ].text;\n\t\tconst keyphraseTokenText = keyphraseTokens[ indexOfWordInKeyphrase ];\n\n\t\tconst foundMatches = matchTextWithTransliteration( sentenceTokenText.toLowerCase(), keyphraseTokenText.toLowerCase(), locale );\n\n\t\tif ( foundMatches.length > 0 ) {\n\t\t\tcurrentMatch.push( sentenceTokens[ indexOfWordInSentence ] );\n\t\t\tindexOfWordInKeyphrase++;\n\t\t} else {\n\t\t\tindexOfWordInKeyphrase = 0;\n\t\t\tcurrentMatch = [];\n\t\t}\n\n\t\t/*\n\t\t * If the current match has the same length as the keyphrase tokens, the keyphrase forms have been matched.\n\t\t * Add the current match to the matches array and reset the index of the word in keyphrase and the current match.\n\t\t */\n\t\tif ( currentMatch.length === keyphraseTokens.length ) {\n\t\t\tresult.matches.push( ...currentMatch );\n\t\t\tresult.count++;\n\t\t\tindexOfWordInKeyphrase = 0;\n\t\t\tcurrentMatch = [];\n\t\t}\n\n\t\tindexOfWordInSentence++;\n\t}\n\treturn result;\n};\n\n/**\n * Matches a word form of the keyphrase with the tokens from the sentence.\n *\n * With this approach, we transliterate the word form of the keyphrase before matching it with the sentence tokens.\n * However, we don't do the transliteration step for the sentence tokens.\n * As a result, for example, the word form \"acción\" from the keyphrase will match the word \"accion\" in the sentence.\n * But, the word form \"accion\" from the keyphrase will NOT match the word \"acción\" in the sentence.\n *\n * @param {Token[]}\ttokens\t\tThe array of tokens to check.\n * @param {string}\twordForm\tThe word form of the keyphrase.\n * @param {string}\tlocale\t\tThe locale used in the analysis.\n *\n * @returns {Token[]}\tThe array of the matched tokens.\n */\nconst matchWordFormInTokens = ( tokens, wordForm, locale ) => {\n\tlet matches = [];\n\n\ttokens.forEach( token => {\n\t\tconst occurrence = matchTextWithTransliteration( token.text, wordForm, locale );\n\t\tif ( occurrence.length > 0 ) {\n\t\t\tmatches = matches.concat( token );\n\t\t}\n\t} );\n\n\treturn matches;\n};\n\n/**\n * Finds keyphrase forms in a sentence.\n *\n * @param {Sentence|string}\tsentence\t\t\t\tThe sentence to check.\n * @param {string[]}\t\twordForms\t\t\t\tThe word forms of the keyphrase to check.\n * @param {string}\t\t\tlocale\t\t\t\t\tThe locale used in the analysis.\n * @param {function}\t\tmatchWordCustomHelper\tCustom function to match a word form with sentence.\n *\n * @returns {{count: number, matches: (Token|string)[]}} Object containing the number of the matches and the matched tokens.\n */\nconst matchWordFormsInSentence = ( sentence, wordForms, locale, matchWordCustomHelper ) => {\n\tconst result = {\n\t\tcount: 0,\n\t\tmatches: [],\n\t};\n\n\twordForms.forEach( wordForm => {\n\t\tlet occurrences = [];\n\t\tif ( matchWordCustomHelper ) {\n\t\t\toccurrences = matchWordCustomHelper( sentence, wordForm );\n\t\t} else {\n\t\t\tconst tokens = sentence.tokens.slice();\n\t\t\toccurrences = matchWordFormInTokens( tokens, wordForm, locale );\n\t\t}\n\t\tresult.count += occurrences.length;\n\t\tresult.matches = result.matches.concat( occurrences );\n\t} );\n\n\treturn result;\n};\n\n/**\n * Matches the word forms of a keyphrase with a sentence object from the html parser.\n *\n * @param {Sentence|string}\tsentence\t\t\t\t\tThe sentence to match against the word forms of a keyphrase.\n * @param {string[]}\t\twordForms\t\t\t\t\tThe array of word forms of the keyphrase.\n * E.g. If the keyphrase is \"key word\", then (if Premium is activated) this will be [ \"key\", \"keys\" ] OR [ \"word\", \"words\" ]\n * The forms are retrieved higher up (among others in keywordCount.js) with researcher.getResearch( \"morphology\" ).\n * @param {string}\t\t\tlocale\t\t\t\t\t\tThe locale used for transliteration.\n * @param {function}\t\tmatchWordCustomHelper\t\tCustom function to match a word form with sentence.\n * @param {boolean}\t\t\tuseExactMatching\t\t\tWhether to match the keyphrase forms exactly or not.\n * \t\t\t\t\t\t\t\t\t\t\t\t\t\tExact match is used when the keyphrase is enclosed in double quotes.\n * @param {function}\t\tcustomSplitIntoTokensHelper\tA custom helper to split sentences into tokens.\n *\n * @returns {{count: number, matches: (Token|string)[]}} Object containing the number of the matches and the matched tokens.\n */\nconst matchWordFormsWithSentence = ( sentence, wordForms, locale, matchWordCustomHelper, useExactMatching = false, customSplitIntoTokensHelper ) => {\n\t/*\n\t * Only use `findExactMatchKeyphraseInSentence` when the custom helper is not available.\n\t * When the custom helper is available, the step for the exact matching happens in the helper.\n\t */\n\tif ( useExactMatching && ! matchWordCustomHelper ) {\n\t\treturn findExactMatchKeyphraseInSentence( sentence, wordForms, locale, customSplitIntoTokensHelper );\n\t}\n\treturn matchWordFormsInSentence( sentence, wordForms, locale, matchWordCustomHelper );\n};\n\nexport default matchWordFormsWithSentence;\n"],"mappings":"AAAA,OAAOA,4BAA4B;AACnC,OAAOC,eAAe;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sCAAsC,GAAGA,CAAEC,SAAS,EAAEC,2BAA2B,KAAM;EAC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EAAEY,QAAQ,EAAElB,MAAO,CAAC;IAChE;IACAC,MAAM,CAACC,KAAK,IAAIuB,WAAW,CAACf,MAAM;IAClCT,MAAM,CAACE,OAAO,GAAGF,MAAM,CAACE,OAAO,CAACmB,MAAM,CAAEG,WAAY,CAAC;EACtD,CAAE,CAAC;EAEH,OAAOxB,MAAM;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM0B,0BAA0B,GAAGA,CAAE5B,QAAQ,EAAEJ,SAAS,EAAEK,MAAM,EAAEwB,qBAAqB,EAAEI,gBAAgB,GAAG,KAAK,EAAEhC,2BAA2B,KAAM;EACnJ;AACD;AACA;AACA;EACC,IAAKgC,gBAAgB,IAAI,CAAEJ,qBAAqB,EAAG;IAClD,OAAO1B,iCAAiC,CAAEC,QAAQ,EAAEJ,SAAS,EAAEK,MAAM,EAAEJ,2BAA4B,CAAC;EACrG;EACA,OAAO2B,wBAAwB,CAAExB,QAAQ,EAAEJ,SAAS,EAAEK,MAAM,EAAEwB,qBAAsB,CAAC;AACtF,CAAC;AAED,eAAeG,0BAA0B","ignoreList":[]}
1
+ {"version":3,"file":"matchWordFormsWithSentence.js","names":["matchTextWithTransliteration","splitIntoTokens","tokenizeKeyphraseFormsForExactMatching","wordForms","customSplitIntoTokensHelper","wordFormText","findExactMatchKeyphraseInSentence","sentence","locale","result","count","matches","keyphraseTokens","sentenceTokens","tokens","indexOfWordInKeyphrase","indexOfWordInSentence","currentMatch","length","sentenceTokenText","text","keyphraseTokenText","foundMatches","toLowerCase","push","matchWordFormInTokens","wordForm","forEach","token","occurrence","concat","matchWordFormsInSentence","matchWordCustomHelper","occurrences","slice","matchWordFormsWithSentence","useExactMatching"],"sources":["../../../../src/languageProcessing/helpers/match/matchWordFormsWithSentence.js"],"sourcesContent":["import matchTextWithTransliteration from './matchTextWithTransliteration';\nimport splitIntoTokens from '../word/splitIntoTokens';\n\n/**\n * Tokenizes the word form of the keyphrase for exact matching. This function gets the word form and tokenizes it.\n * This function assumes that if a keyphrase needs to be matched exactly, there will be only one word form.\n * This is the result of how the focus keyphrase is processed in buildTopicStems.js in the buildStems function.\n *\n * @param {(string[])} wordForms \t\t\t\t\tThe word forms to tokenize.\n * @param {function}\tcustomSplitIntoTokensHelper\tA custom helper to split sentences into tokens.\n *\n * @returns {string[]} The tokenized word forms.\n */\nexport const tokenizeKeyphraseFormsForExactMatching = (wordForms, customSplitIntoTokensHelper) => {\n // Tokenize word form of the keyphrase.\n const wordFormText = wordForms[0];\n\n return customSplitIntoTokensHelper\n ? customSplitIntoTokensHelper(wordFormText)\n : splitIntoTokens(wordFormText);\n};\n\n/**\n * Gets the exact matches of the keyphrase.\n * Exact matching happens when the user puts the keyphrase in double quotes.\n *\n * @param {Sentence}\tsentence\t\t\t\t\tThe sentence to match the word forms with.\n * @param {string[]}\twordForms\t\t\t\t\tThe word forms to match.\n * @param {string}\t\tlocale\t\t\t\t\t\tThe locale used in the analysis.\n * @param {function}\tcustomSplitIntoTokensHelper\tA custom helper to split sentences into tokens.\n *\n * @returns {{count: number, matches: Token[]}} Object containing the number of the exact matches and the matched tokens.\n */\nconst findExactMatchKeyphraseInSentence = (\n sentence,\n wordForms,\n locale,\n customSplitIntoTokensHelper\n) => {\n const result = {\n count: 0,\n matches: []\n };\n // Tokenize word forms of the keyphrase.\n const keyphraseTokens = tokenizeKeyphraseFormsForExactMatching(\n wordForms,\n customSplitIntoTokensHelper\n );\n const sentenceTokens = sentence.tokens;\n\n // Initialize the index of the word token of the keyphrase.\n let indexOfWordInKeyphrase = 0;\n // Initialize the index of the word token of the sentence.\n let indexOfWordInSentence = 0;\n let currentMatch = [];\n // Check if the tokenized word forms occur in the same order in the sentence tokens.\n while (indexOfWordInSentence < sentenceTokens.length) {\n // If the current sentence token matches the current word token of the keyphrase, add it to the current match.\n const sentenceTokenText = sentenceTokens[indexOfWordInSentence].text;\n const keyphraseTokenText = keyphraseTokens[indexOfWordInKeyphrase];\n\n const foundMatches = matchTextWithTransliteration(\n sentenceTokenText.toLowerCase(),\n keyphraseTokenText.toLowerCase(),\n locale\n );\n\n if (foundMatches.length > 0) {\n currentMatch.push(sentenceTokens[indexOfWordInSentence]);\n indexOfWordInKeyphrase++;\n } else {\n indexOfWordInKeyphrase = 0;\n currentMatch = [];\n }\n\n /*\n * If the current match has the same length as the keyphrase tokens, the keyphrase forms have been matched.\n * Add the current match to the matches array and reset the index of the word in keyphrase and the current match.\n */\n if (currentMatch.length === keyphraseTokens.length) {\n result.matches.push(...currentMatch);\n result.count++;\n indexOfWordInKeyphrase = 0;\n currentMatch = [];\n }\n\n indexOfWordInSentence++;\n }\n return result;\n};\n\n/**\n * Matches a word form of the keyphrase with the tokens from the sentence.\n *\n * With this approach, we transliterate the word form of the keyphrase before matching it with the sentence tokens.\n * However, we don't do the transliteration step for the sentence tokens.\n * As a result, for example, the word form \"acción\" from the keyphrase will match the word \"accion\" in the sentence.\n * But, the word form \"accion\" from the keyphrase will NOT match the word \"acción\" in the sentence.\n *\n * @param {Token[]}\ttokens\t\tThe array of tokens to check.\n * @param {string}\twordForm\tThe word form of the keyphrase.\n * @param {string}\tlocale\t\tThe locale used in the analysis.\n *\n * @returns {Token[]}\tThe array of the matched tokens.\n */\nconst matchWordFormInTokens = (tokens, wordForm, locale) => {\n let matches = [];\n\n tokens.forEach(token => {\n const occurrence = matchTextWithTransliteration(token.text.toLowerCase(), wordForm, locale);\n if (occurrence.length > 0) {\n matches = matches.concat(token);\n }\n });\n\n return matches;\n};\n\n/**\n * Finds keyphrase forms in a sentence.\n *\n * @param {Sentence|string}\tsentence\t\t\t\tThe sentence to check.\n * @param {string[]}\t\twordForms\t\t\t\tThe word forms of the keyphrase to check.\n * @param {string}\t\t\tlocale\t\t\t\t\tThe locale used in the analysis.\n * @param {function}\t\tmatchWordCustomHelper\tCustom function to match a word form with sentence.\n *\n * @returns {{count: number, matches: (Token|string)[]}} Object containing the number of the matches and the matched tokens.\n */\nconst matchWordFormsInSentence = (sentence, wordForms, locale, matchWordCustomHelper) => {\n const result = {\n count: 0,\n matches: []\n };\n\n wordForms.forEach(wordForm => {\n let occurrences = [];\n if (matchWordCustomHelper) {\n occurrences = matchWordCustomHelper(sentence, wordForm);\n } else {\n const tokens = sentence.tokens.slice();\n occurrences = matchWordFormInTokens(tokens, wordForm, locale);\n }\n result.count += occurrences.length;\n result.matches = result.matches.concat(occurrences);\n });\n\n return result;\n};\n\n/**\n * Matches the word forms of a keyphrase with a sentence object from the html parser.\n *\n * @param {Sentence|string}\tsentence\t\t\t\t\tThe sentence to match against the word forms of a keyphrase.\n * @param {string[]}\t\twordForms\t\t\t\t\tThe array of word forms of the keyphrase.\n * E.g. If the keyphrase is \"key word\", then (if Premium is activated) this will be [ \"key\", \"keys\" ] OR [ \"word\", \"words\" ]\n * The forms are retrieved higher up (among others in keywordCount.js) with researcher.getResearch( \"morphology\" ).\n * @param {string}\t\t\tlocale\t\t\t\t\t\tThe locale used for transliteration.\n * @param {function}\t\tmatchWordCustomHelper\t\tCustom function to match a word form with sentence.\n * @param {boolean}\t\t\tuseExactMatching\t\t\tWhether to match the keyphrase forms exactly or not.\n * \t\t\t\t\t\t\t\t\t\t\t\t\t\tExact match is used when the keyphrase is enclosed in double quotes.\n * @param {function}\t\tcustomSplitIntoTokensHelper\tA custom helper to split sentences into tokens.\n *\n * @returns {{count: number, matches: (Token|string)[]}} Object containing the number of the matches and the matched tokens.\n */\nconst matchWordFormsWithSentence = (\n sentence,\n wordForms,\n locale,\n matchWordCustomHelper,\n useExactMatching = false,\n customSplitIntoTokensHelper\n) => {\n /*\n * Only use `findExactMatchKeyphraseInSentence` when the custom helper is not available.\n * When the custom helper is available, the step for the exact matching happens in the helper.\n */\n if (useExactMatching && !matchWordCustomHelper) {\n return findExactMatchKeyphraseInSentence(\n sentence,\n wordForms,\n locale,\n customSplitIntoTokensHelper\n );\n }\n return matchWordFormsInSentence(sentence, wordForms, locale, matchWordCustomHelper);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AAE;MACzBC,WAAW,GAAGD,qBAAqB,CAACzB,QAAQ,EAAEmB,QAAQ,CAAC;IACzD,CAAC,MAAM;MACL,MAAMZ,MAAM,GAAGP,QAAQ,CAACO,MAAM,CAACoB,KAAK,CAAC,CAAC;MACtCD,WAAW,GAAGR,qBAAqB,CAACX,MAAM,EAAEY,QAAQ,EAAElB,MAAM,CAAC;IAC/D;IACAC,MAAM,CAACC,KAAK,IAAIuB,WAAW,CAACf,MAAM;IAClCT,MAAM,CAACE,OAAO,GAAGF,MAAM,CAACE,OAAO,CAACmB,MAAM,CAACG,WAAW,CAAC;EACrD,CAAC,CAAC;EAEF,OAAOxB,MAAM;AACf,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM0B,0BAA0B,GAAGA,CACjC5B,QAAQ,EACRJ,SAAS,EACTK,MAAM,EACNwB,qBAAqB,EACrBI,gBAAgB,GAAG,KAAK,EACxBhC,2BAA2B,KACxB;EACH;AACF;AACA;AACA;EACE,IAAIgC,gBAAgB,IAAI,CAACJ,qBAAqB,EAAE;IAC9C,OAAO1B,iCAAiC,CACtCC,QAAQ,EACRJ,SAAS,EACTK,MAAM,EACNJ,2BACF,CAAC;EACH;EACA,OAAO2B,wBAAwB,CAACxB,QAAQ,EAAEJ,SAAS,EAAEK,MAAM,EAAEwB,qBAAqB,CAAC;AACrF,CAAC;AAED,eAAeG,0BAA0B","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  /** @module analyses/findKeywordInFirstParagraph */
2
- import { inRange, isEmpty } from "lodash";
2
+ import { inRange, isEmpty } from 'lodash';
3
3
  import { findTopicFormsInString } from "../helpers/match/findKeywordFormsInString.js";
4
4
  import { getParentNode } from "../helpers/sentence/getSentencesFromTree";
5
5
  import { createShortcodeTagsRegex } from "../helpers";
@@ -24,19 +24,19 @@ import { createShortcodeTagsRegex } from "../helpers";
24
24
  * the paragraph, whether a keyphrase or a synonym phrase was matched.
25
25
  */
26
26
  export default function (paper, researcher) {
27
- let paragraphs = researcher.getResearch("getParagraphs");
27
+ let paragraphs = researcher.getResearch('getParagraphs');
28
28
  // Filter captions from non-Classic editors.
29
29
  paragraphs = paragraphs.filter(paragraph => {
30
30
  const parentNode = getParentNode(paper, paragraph);
31
- return !(paragraph.isImplicit && parentNode && parentNode.name === "figcaption");
31
+ return !(paragraph.isImplicit && parentNode && parentNode.name === 'figcaption');
32
32
  });
33
33
  // Filter captions from Classic editor and from classic block inside Block editor.
34
34
  paragraphs = paragraphs.filter(paragraph => {
35
- return !(paragraph.childNodes && paragraph.childNodes[0] && createShortcodeTagsRegex(["caption"]).test(paragraph.childNodes[0].value));
35
+ return !(paragraph.childNodes && paragraph.childNodes[0] && createShortcodeTagsRegex(['caption']).test(paragraph.childNodes[0].value));
36
36
  });
37
37
  const firstParagraph = paragraphs[0];
38
- const topicForms = researcher.getResearch("morphology");
39
- const matchWordCustomHelper = researcher.getHelper("matchWordCustomHelper");
38
+ const topicForms = researcher.getResearch('morphology');
39
+ const matchWordCustomHelper = researcher.getHelper('matchWordCustomHelper');
40
40
  const locale = paper.getLocale();
41
41
  const startOffset = firstParagraph && firstParagraph.sourceCodeLocation.startOffset;
42
42
  const mappedBlocks = paper._attributes.wpBlocks;
@@ -44,7 +44,7 @@ export default function (paper, researcher) {
44
44
  const result = {
45
45
  foundInOneSentence: false,
46
46
  foundInParagraph: false,
47
- keyphraseOrSynonym: "",
47
+ keyphraseOrSynonym: '',
48
48
  introduction: firstParagraph,
49
49
  parentBlock: filteredIntroductionBlock || null
50
50
  };
@@ -1 +1 @@
1
- {"version":3,"file":"findKeywordInFirstParagraph.js","names":["inRange","isEmpty","findTopicFormsInString","getParentNode","createShortcodeTagsRegex","paper","researcher","paragraphs","getResearch","filter","paragraph","parentNode","isImplicit","name","childNodes","test","value","firstParagraph","topicForms","matchWordCustomHelper","getHelper","locale","getLocale","startOffset","sourceCodeLocation","mappedBlocks","_attributes","wpBlocks","filteredIntroductionBlock","block","endOffset","result","foundInOneSentence","foundInParagraph","keyphraseOrSynonym","introduction","parentBlock","sentences","map","sentence","text","useSynonyms","firstResultSentence","find","resultSentence","percentWordMatches","resultParagraph","innerText"],"sources":["../../../src/languageProcessing/researches/findKeywordInFirstParagraph.js"],"sourcesContent":["/** @module analyses/findKeywordInFirstParagraph */\nimport { inRange, isEmpty } from \"lodash\";\n\nimport { findTopicFormsInString } from \"../helpers/match/findKeywordFormsInString.js\";\nimport { getParentNode } from \"../helpers/sentence/getSentencesFromTree\";\nimport { createShortcodeTagsRegex } from \"../helpers\";\n\n\n/**\n * Checks if the introductory paragraph contains keyphrase or synonyms.\n * First splits the first paragraph by sentences. Finds the first paragraph which contains sentences e.g., not an image).\n * (1) Tries to find all (content) words from the keyphrase or a synonym phrase within one sentence.\n * If found all words within one sentence, returns an object with foundInOneSentence = true and keyphraseOrSynonym = \"keyphrase\"\n * or \"synonym\".\n * If it did not find all words within one sentence, goes ahead with matching the keyphrase with the entire first paragraph.\n * (2) Tries to find all (content) words from the keyphrase or a synonym phrase within the paragraph.\n * If found all words within the paragraph, returns an object with foundInOneSentence = false, foundInParagraph = true,\n * and keyphraseOrSynonym = \"keyphrase\" or \"synonym\".\n * If found not all words within the paragraph of nothing at all, returns an object with foundInOneSentence = false,\n * foundInParagraph = false, and keyphraseOrSynonym = \"\".\n *\n * @param {Paper} paper The text to check for paragraphs.\n * @param {Researcher} researcher The researcher to use for analysis.\n *\n * @returns {Object} Whether the keyphrase words were found in one sentence, whether the keyphrase words were found in\n * the paragraph, whether a keyphrase or a synonym phrase was matched.\n */\nexport default function( paper, researcher ) {\n\tlet paragraphs = researcher.getResearch( \"getParagraphs\" );\n\t// Filter captions from non-Classic editors.\n\tparagraphs = paragraphs.filter( paragraph => {\n\t\tconst parentNode = getParentNode( paper, paragraph );\n\t\treturn ! ( paragraph.isImplicit && parentNode && parentNode.name === \"figcaption\" );\n\t} );\n\t// Filter captions from Classic editor and from classic block inside Block editor.\n\tparagraphs = paragraphs.filter( paragraph => {\n\t\treturn ! ( paragraph.childNodes && paragraph.childNodes[ 0 ] &&\n\t\t\tcreateShortcodeTagsRegex( [ \"caption\" ] ).test( paragraph.childNodes[ 0 ].value ) );\n\t} );\n\t const firstParagraph = paragraphs[ 0 ];\n\n\tconst topicForms = researcher.getResearch( \"morphology\" );\n\tconst matchWordCustomHelper = researcher.getHelper( \"matchWordCustomHelper\" );\n\tconst locale = paper.getLocale();\n\tconst startOffset = firstParagraph && firstParagraph.sourceCodeLocation.startOffset;\n\n\tconst mappedBlocks = paper._attributes.wpBlocks;\n\tconst filteredIntroductionBlock = mappedBlocks && mappedBlocks.filter( block => inRange( startOffset, block.startOffset, block.endOffset ) )[ 0 ];\n\tconst result = {\n\t\tfoundInOneSentence: false,\n\t\tfoundInParagraph: false,\n\t\tkeyphraseOrSynonym: \"\",\n\t\tintroduction: firstParagraph,\n\t\tparentBlock: filteredIntroductionBlock || null,\n\t};\n\n\tif ( isEmpty( firstParagraph ) ) {\n\t\treturn result;\n\t}\n\n\tconst sentences = firstParagraph.sentences.map( sentence => sentence.text );\n\t// Use both keyphrase and synonyms to match topic words in the first paragraph.\n\tconst useSynonyms = true;\n\n\tif ( ! isEmpty( sentences ) ) {\n\t\tconst firstResultSentence = sentences\n\t\t\t.map( sentence => findTopicFormsInString( topicForms, sentence, useSynonyms, locale, matchWordCustomHelper ) )\n\t\t\t.find( resultSentence => resultSentence.percentWordMatches === 100 );\n\n\t\tif ( firstResultSentence ) {\n\t\t\tresult.foundInOneSentence = true;\n\t\t\tresult.foundInParagraph = true;\n\t\t\tresult.keyphraseOrSynonym = firstResultSentence.keyphraseOrSynonym;\n\t\t\treturn result;\n\t\t}\n\n\t\tconst resultParagraph = findTopicFormsInString( topicForms, firstParagraph.innerText(), useSynonyms, locale, matchWordCustomHelper );\n\t\tif ( resultParagraph.percentWordMatches === 100 ) {\n\t\t\tresult.foundInParagraph = true;\n\t\t\tresult.keyphraseOrSynonym = resultParagra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AAEpB,MAAM,EAAEF,qBAAsB,CAAC;IACpI,IAAK2B,eAAe,CAACD,kBAAkB,KAAK,GAAG,EAAG;MACjDd,MAAM,CAACE,gBAAgB,GAAG,IAAI;MAC9BF,MAAM,CAACG,kBAAkB,GAAGY,eAAe,CAACZ,kBAAkB;MAC9D,OAAOH,MAAM;IACd;EACD;EAEA,OAAOA,MAAM;AACd","ignoreList":[]}
1
+ {"version":3,"file":"findKeywordInFirstParagraph.js","names":["inRange","isEmpty","findTopicFormsInString","getParentNode","createShortcodeTagsRegex","paper","researcher","paragraphs","getResearch","filter","paragraph","parentNode","isImplicit","name","childNodes","test","value","firstParagraph","topicForms","matchWordCustomHelper","getHelper","locale","getLocale","startOffset","sourceCodeLocation","mappedBlocks","_attributes","wpBlocks","filteredIntroductionBlock","block","endOffset","result","foundInOneSentence","foundInParagraph","keyphraseOrSynonym","introduction","parentBlock","sentences","map","sentence","text","useSynonyms","firstResultSentence","find","resultSentence","percentWordMatches","resultParagraph","innerText"],"sources":["../../../src/languageProcessing/researches/findKeywordInFirstParagraph.js"],"sourcesContent":["/** @module analyses/findKeywordInFirstParagraph */\nimport {inRange, isEmpty} from 'lodash';\n\nimport {findTopicFormsInString} from '../helpers/match/findKeywordFormsInString.js';\nimport {getParentNode} from '../helpers/sentence/getSentencesFromTree';\nimport {createShortcodeTagsRegex} from '../helpers';\n\n/**\n * Checks if the introductory paragraph contains keyphrase or synonyms.\n * First splits the first paragraph by sentences. Finds the first paragraph which contains sentences e.g., not an image).\n * (1) Tries to find all (content) words from the keyphrase or a synonym phrase within one sentence.\n * If found all words within one sentence, returns an object with foundInOneSentence = true and keyphraseOrSynonym = \"keyphrase\"\n * or \"synonym\".\n * If it did not find all words within one sentence, goes ahead with matching the keyphrase with the entire first paragraph.\n * (2) Tries to find all (content) words from the keyphrase or a synonym phrase within the paragraph.\n * If found all words within the paragraph, returns an object with foundInOneSentence = false, foundInParagraph = true,\n * and keyphraseOrSynonym = \"keyphrase\" or \"synonym\".\n * If found not all words within the paragraph of nothing at all, returns an object with foundInOneSentence = false,\n * foundInParagraph = false, and keyphraseOrSynonym = \"\".\n *\n * @param {Paper} paper The text to check for paragraphs.\n * @param {Researcher} researcher The researcher to use for analysis.\n *\n * @returns {Object} Whether the keyphrase words were found in one sentence, whether the keyphrase words were found in\n * the paragraph, whether a keyphrase or a synonym phrase was matched.\n */\nexport default function(paper, researcher) {\n let paragraphs = researcher.getResearch('getParagraphs');\n // Filter captions from non-Classic editors.\n paragraphs = paragraphs.filter(paragraph => {\n const parentNode = getParentNode(paper, paragraph);\n return !(paragraph.isImplicit && parentNode && parentNode.name === 'figcaption');\n });\n // Filter captions from Classic editor and from classic block inside Block editor.\n paragraphs = paragraphs.filter(paragraph => {\n return !(\n paragraph.childNodes &&\n paragraph.childNodes[0] &&\n createShortcodeTagsRegex(['caption']).test(paragraph.childNodes[0].value)\n );\n });\n const firstParagraph = paragraphs[0];\n\n const topicForms = researcher.getResearch('morphology');\n const matchWordCustomHelper = researcher.getHelper('matchWordCustomHelper');\n const locale = paper.getLocale();\n const startOffset = firstParagraph && firstParagraph.sourceCodeLocation.startOffset;\n\n const mappedBlocks = paper._attributes.wpBlocks;\n const filteredIntroductionBlock =\n mappedBlocks &&\n mappedBlocks.filter(block => inRange(startOffset, block.startOffset, block.endOffset))[0];\n const result = {\n foundInOneSentence: false,\n foundInParagraph: false,\n keyphraseOrSynonym: '',\n introduction: firstParagraph,\n parentBlock: filteredIntroductionBlock || null\n };\n\n if (isEmpty(firstParagraph)) {\n return result;\n }\n\n const sentences = firstParagraph.sentences.map(sentence => sentence.text);\n // Use both keyphrase and synonyms to match topic words in the first paragraph.\n const useSynonyms = true;\n\n if (!isEmpty(sentences)) {\n const firstResultSentence = sentences\n .map(sentence =>\n findTopicFormsInString(topicForms, sentence, useSynonyms, locale, matchWordCustomHelper)\n )\n .find(resultSentence => resultSentence.percentWordMatches === 100);\n\n if (firstResultSentence) {\n result.foundInOneSentence = true;\n result.foundInParagraph = true;\n result.keyphraseOrSynonym = firstResultSentence.keyphraseOrSynonym;\n return result;\n }\n\n const resultParagraph = findTopicFormsInString(\n topicForms,\n firstParagraph.innerText(),\n useSynonyms,\n locale,\n matchWordCustomHelper\n );\n if (resultParagraph.percentWordMatches === 100) {\n result.foundInParagraph = true;\n result.keyphraseOrSynonym = resultParagraph.keyphraseOrSynonym;\n return result;\n }\n }\n\n return result;\n}\n"],"mappings":"AAAA;AACA,SAAQA,OAAO,EAAEC,OAAO,QAAO,QAAQ;AAEvC,SAAQC,sBAAsB;AAC9B,SAAQC,aAAa;AACrB,SAAQC,wBAAwB;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,UAASC,KAAK,EAAEC,UAAU,EAAE;EACzC,IAAIC,UAAU,GAAGD,UAAU,CAACE,WAAW,CAAC,eAAe,CAAC;EACxD;EACAD,UAAU,GAAGA,UAAU,CAACE,MAAM,CAACC,SAAS,IAAI;IAC1C,MAAMC,UAAU,GAAGR,aAAa,CAACE,KAAK,EAAEK,SAAS,CAAC;IAClD,OAAO,EAAEA,SAAS,CAACE,UAAU,IAAID,UAAU,IAAIA,UAAU,CAACE,IAAI,KAAK,YAAY,CAAC;EAClF,CAAC,CAAC;EACF;EACAN,UAAU,GAAGA,UAAU,CAACE,MAAM,CAACC,SAAS,IAAI;IAC1C,OAAO,EACLA,SAAS,CAACI,UAAU,IACpBJ,SAAS,CAACI,UAAU,CAAC,CAAC,CAAC,IACvBV,wBAAwB,CAAC,CAAC,SAAS,CAAC,CAAC,CAACW,IAAI,CAACL,SAAS,CAACI,UAAU,CAAC,CAAC,CAAC,CAACE,KAAK,CAAC,CAC1E;EACH,CAAC,CAAC;EACF,MAAMC,cAAc,GAAGV,UAAU,CAAC,CAAC,CAAC;EAEpC,MAAMW,UAAU,GAAGZ,UAAU,CAACE,WAAW,CAAC,YAAY,CAAC;EACvD,MAAMW,qBAA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kBAAkB,GAAGQ,mBAAmB,CAACR,kBAAkB;MAClE,OAAOH,MAAM;IACf;IAEA,MAAMe,eAAe,GAAG5C,sBAAsB,CAC5CgB,UAAU,EACVD,cAAc,CAAC8B,SAAS,CAAC,CAAC,EAC1BN,WAAW,EACXpB,MAAM,EACNF,qBACF,CAAC;IACD,IAAI2B,eAAe,CAACD,kBAAkB,KAAK,GAAG,EAAE;MAC9Cd,MAAM,CAACE,gBAAgB,GAAG,IAAI;MAC9BF,MAAM,CAACG,kBAAkB,GAAGY,eAAe,CAACZ,kBAAkB;MAC9D,OAAOH,MAAM;IACf;EACF;EAEA,OAAOA,MAAM;AACf","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import getAllWordsFromTree from "../helpers/word/getAllWordsFromTree";
1
+ import countWords from "../helpers/word/countWords";
2
2
 
3
3
  /**
4
4
  * Calculates the keyphrase density.
@@ -9,19 +9,19 @@ import getAllWordsFromTree from "../helpers/word/getAllWordsFromTree";
9
9
  * @returns {number} The keyphrase density.
10
10
  */
11
11
  export default function getKeyphraseDensity(paper, researcher) {
12
- const getWordsCustomHelper = researcher.getHelper("getWordsCustomHelper");
12
+ const getWordsCustomHelper = researcher.getHelper('getWordsCustomHelper');
13
13
  let wordCount = 0;
14
14
 
15
15
  // If there is a custom getWords helper, use its output for countWords.
16
16
  if (getWordsCustomHelper) {
17
17
  wordCount = getWordsCustomHelper(paper.getText()).length;
18
18
  } else {
19
- wordCount = getAllWordsFromTree(paper).length;
19
+ wordCount = countWords(paper.getText());
20
20
  }
21
21
  if (wordCount === 0) {
22
22
  return 0;
23
23
  }
24
- const keyphraseCount = researcher.getResearch("getKeyphraseCount");
24
+ const keyphraseCount = researcher.getResearch('getKeyphraseCount');
25
25
  return keyphraseCount.count / wordCount * 100;
26
26
  }
27
27
 
@@ -36,7 +36,7 @@ export default function getKeyphraseDensity(paper, researcher) {
36
36
  * @returns {number} The keyphrase density.
37
37
  */
38
38
  export function getKeywordDensity(paper, researcher) {
39
- console.warn("This function is deprecated, use getKeyphraseDensity instead.");
39
+ console.warn('This function is deprecated, use getKeyphraseDensity instead.');
40
40
  return getKeyphraseDensity(paper, researcher);
41
41
  }
42
42
  //# sourceMappingURL=getKeywordDensity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getKeywordDensity.js","names":["getAllWordsFromTree","getKeyphraseDensity","paper","researcher","getWordsCustomHelper","getHelper","wordCount","getText","length","keyphraseCount","getResearch","count","getKeywordDensity","console","warn"],"sources":["../../../src/languageProcessing/researches/getKeywordDensity.js"],"sourcesContent":["import getAllWordsFromTree from \"../helpers/word/getAllWordsFromTree\";\n\n/**\n * Calculates the keyphrase density.\n *\n * @param {Paper} paper The paper containing keyphrase and text.\n * @param {Researcher} researcher The researcher.\n *\n * @returns {number} The keyphrase density.\n */\nexport default function getKeyphraseDensity( paper, researcher ) {\n\tconst getWordsCustomHelper = researcher.getHelper( \"getWordsCustomHelper\" );\n\tlet wordCount = 0;\n\n\t// If there is a custom getWords helper, use its output for countWords.\n\tif ( getWordsCustomHelper ) {\n\t\twordCount = getWordsCustomHelper( paper.getText() ).length;\n\t} else {\n\t\twordCount = getAllWordsFromTree( paper ).length;\n\t}\n\n\tif ( wordCount === 0 ) {\n\t\treturn 0;\n\t}\n\n\tconst keyphraseCount = researcher.getResearch( \"getKeyphraseCount\" );\n\n\treturn ( keyphraseCount.count / wordCount ) * 100;\n}\n\n/**\n * Calculates the keyphrase density.\n *\n * @deprecated Use getKeyphraseDensity instead.\n *\n * @param {Paper} paper The paper containing keyphrase and text.\n * @param {Researcher} researcher The researcher.\n *\n * @returns {number} The keyphrase density.\n */\nexport function getKeywordDensity( paper, researcher ) {\n\tconsole.warn( \"This function is deprecated, use getKeyphraseDensity instead.\" );\n\treturn getKeyphraseDensity( paper, researcher );\n}\n"],"mappings":"AAAA,OAAOA,mBAAmB;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,mBAAmBA,CAAEC,KAAK,EAAEC,UAAU,EAAG;EAChE,MAAMC,oBAAoB,GAAGD,UAAU,CAACE,SAAS,CAAE,sBAAuB,CAAC;EAC3E,IAAIC,SAAS,GAAG,CAAC;;EAEjB;EACA,IAAKF,oBAAoB,EAAG;IAC3BE,SAAS,GAAGF,oBAAoB,CAAEF,KAAK,CAACK,OAAO,CAAC,CAAE,CAAC,CAACC,MAAM;EAC3D,CAAC,MAAM;IACNF,SAAS,GAAGN,mBAAmB,CAAEE,KAAM,CAAC,CAACM,MAAM;EAChD;EAEA,IAAKF,SAAS,KAAK,CAAC,EAAG;IACtB,OAAO,CAAC;EACT;EAEA,MAAMG,cAAc,GAAGN,UAAU,CAACO,WAAW,CAAE,mBAAoB,CAAC;EAEpE,OAASD,cAAc,CAACE,KAAK,GAAGL,SAAS,GAAK,GAAG;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,iBAAiBA,CAAEV,KAAK,EAAEC,UAAU,EAAG;EACtDU,OAAO,CAACC,IAAI,CAAE,+DAAgE,CAAC;EAC/E,OAAOb,mBAAmB,CAAEC,KAAK,EAAEC,UAAW,CAAC;AAChD","ignoreList":[]}
1
+ {"version":3,"file":"getKeywordDensity.js","names":["countWords","getKeyphraseDensity","paper","researcher","getWordsCustomHelper","getHelper","wordCount","getText","length","keyphraseCount","getResearch","count","getKeywordDensity","console","warn"],"sources":["../../../src/languageProcessing/researches/getKeywordDensity.js"],"sourcesContent":["import countWords from '@axyseo/languageProcessing/helpers/word/countWords';\n\n/**\n * Calculates the keyphrase density.\n *\n * @param {Paper} paper The paper containing keyphrase and text.\n * @param {Researcher} researcher The researcher.\n *\n * @returns {number} The keyphrase density.\n */\nexport default function getKeyphraseDensity(paper, researcher) {\n const getWordsCustomHelper = researcher.getHelper('getWordsCustomHelper');\n let wordCount = 0;\n\n // If there is a custom getWords helper, use its output for countWords.\n if (getWordsCustomHelper) {\n wordCount = getWordsCustomHelper(paper.getText()).length;\n } else {\n wordCount = countWords(paper.getText());\n }\n\n if (wordCount === 0) {\n return 0;\n }\n const keyphraseCount = researcher.getResearch('getKeyphraseCount');\n\n return (keyphraseCount.count / wordCount) * 100;\n}\n\n/**\n * Calculates the keyphrase density.\n *\n * @deprecated Use getKeyphraseDensity instead.\n *\n * @param {Paper} paper The paper containing keyphrase and text.\n * @param {Researcher} researcher The researcher.\n *\n * @returns {number} The keyphrase density.\n */\nexport function getKeywordDensity(paper, researcher) {\n console.warn('This function is deprecated, use getKeyphraseDensity instead.');\n return getKeyphraseDensity(paper, researcher);\n}\n"],"mappings":"AAAA,OAAOA,UAAU;;AAEjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,mBAAmBA,CAACC,KAAK,EAAEC,UAAU,EAAE;EAC7D,MAAMC,oBAAoB,GAAGD,UAAU,CAACE,SAAS,CAAC,sBAAsB,CAAC;EACzE,IAAIC,SAAS,GAAG,CAAC;;EAEjB;EACA,IAAIF,oBAAoB,EAAE;IACxBE,SAAS,GAAGF,oBAAoB,CAACF,KAAK,CAACK,OAAO,CAAC,CAAC,CAAC,CAACC,MAAM;EAC1D,CAAC,MAAM;IACLF,SAAS,GAAGN,UAAU,CAACE,KAAK,CAACK,OAAO,CAAC,CAAC,CAAC;EACzC;EAEA,IAAID,SAAS,KAAK,CAAC,EAAE;IACnB,OAAO,CAAC;EACV;EACA,MAAMG,cAAc,GAAGN,UAAU,CAACO,WAAW,CAAC,mBAAmB,CAAC;EAElE,OAAQD,cAAc,CAACE,KAAK,GAAGL,SAAS,GAAI,GAAG;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,iBAAiBA,CAACV,KAAK,EAAEC,UAAU,EAAE;EACnDU,OAAO,CAACC,IAAI,CAAC,+DAA+D,CAAC;EAC7E,OAAOb,mBAAmB,CAACC,KAAK,EAAEC,UAAU,CAAC;AAC/C","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { flatten, flattenDeep } from "lodash";
1
+ import { flatten, flattenDeep } from 'lodash';
2
2
  import getSentencesFromTree from "../helpers/sentence/getSentencesFromTree";
3
3
  import { normalizeSingle } from "../helpers/sanitize/quotes";
4
4
  import getMarkingsInSentence from "../helpers/highlighting/getMarkingsInSentence";
@@ -27,7 +27,6 @@ export function countKeyphraseInText(sentences, keyphraseForms, locale, matchWor
27
27
  };
28
28
  sentences.forEach(sentence => {
29
29
  const matchesInSentence = keyphraseForms.map(wordForms => matchWordFormsWithSentence(sentence, wordForms, locale, matchWordCustomHelper, isExactMatchRequested, customSplitIntoTokensHelper));
30
-
31
30
  // A sentence has at least one full-match of the keyphrase if each word occurs at least once.
32
31
  const isEachWordFound = matchesInSentence.every(wordForms => wordForms.count > 0);
33
32
  if (isEachWordFound) {
@@ -75,7 +74,7 @@ export default function getKeyphraseCount(paper, researcher) {
75
74
  markings: [],
76
75
  keyphraseLength: 0
77
76
  };
78
- const topicForms = researcher.getResearch("morphology");
77
+ const topicForms = researcher.getResearch('morphology');
79
78
  let keyphraseForms = topicForms.keyphraseForms;
80
79
  const keyphraseLength = keyphraseForms.length;
81
80
 
@@ -87,9 +86,9 @@ export default function getKeyphraseCount(paper, researcher) {
87
86
  if (keyphraseLength === 0) {
88
87
  return result;
89
88
  }
90
- const matchWordCustomHelper = researcher.getHelper("matchWordCustomHelper");
91
- const customSentenceTokenizer = researcher.getHelper("memoizedTokenizer");
92
- const customSplitIntoTokensHelper = researcher.getHelper("splitIntoTokensCustom");
89
+ const matchWordCustomHelper = researcher.getHelper('matchWordCustomHelper');
90
+ const customSentenceTokenizer = researcher.getHelper('memoizedTokenizer');
91
+ const customSplitIntoTokensHelper = researcher.getHelper('splitIntoTokensCustom');
93
92
  const locale = paper.getLocale();
94
93
  const text = matchWordCustomHelper ? filterShortcodesFromHTML(paper.getText(), paper._attributes && paper._attributes.shortcodes) : paper.getText();
95
94
 
@@ -99,10 +98,10 @@ export default function getKeyphraseCount(paper, researcher) {
99
98
  const isExactMatchRequested = isDoubleQuoted(paper.getKeyword());
100
99
 
101
100
  /*
102
- * Count the amount of keyphrase occurrences in the sentences.
103
- * An occurrence is counted when all words of the keyphrase are contained within the sentence. Each sentence can contain multiple keyphrases.
104
- * (e.g. "The apple potato is an apple and a potato." has two occurrences of the keyphrase "apple potato").
105
- */
101
+ * Count the amount of keyphrase occurrences in the sentences.
102
+ * An occurrence is counted when all words of the keyphrase are contained within the sentence. Each sentence can contain multiple keyphrases.
103
+ * (e.g. "The apple potato is an apple and a potato." has two occurrences of the keyphrase "apple potato").
104
+ */
106
105
  const keyphraseFound = countKeyphraseInText(sentences, keyphraseForms, locale, matchWordCustomHelper, isExactMatchRequested, customSplitIntoTokensHelper);
107
106
  result.count = keyphraseFound.count;
108
107
  result.markings = flatten(keyphraseFound.markings);
@@ -121,7 +120,7 @@ export default function getKeyphraseCount(paper, researcher) {
121
120
  * @returns {Object} An array of all the matches, markings and the keyphrase count.
122
121
  */
123
122
  export function keywordCount(paper, researcher) {
124
- console.warn("This function is deprecated, use getKeyphraseCount instead.");
123
+ console.warn('This function is deprecated, use getKeyphraseCount instead.');
125
124
  return getKeyphraseCount(paper, researcher);
126
125
  }
127
126
  //# sourceMappingURL=keywordCount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keywordCount.js","names":["flatten","flattenDeep","getSentencesFromTree","normalizeSingle","getMarkingsInSentence","matchWordFormsWithSentence","isDoubleQuoted","markWordsInASentence","getSentences","filterShortcodesFromHTML","countKeyphraseInText","sentences","keyphraseForms","locale","matchWordCustomHelper","isExactMatchRequested","customSplitIntoTokensHelper","result","count","markings","forEach","sentence","matchesInSentence","map","wordForms","isEachWordFound","every","counts","match","totalMatchCount","Math","min","foundWords","matches","push","getKeyphraseCount","paper","researcher","keyphraseLength","topicForms","getResearch","length","word","form","getHelper","customSentenceTokenizer","getLocale","text","getText","_attributes","shortcodes","getKeyword","keyphraseFound","keywordCount","console","warn"],"sources":["../../../src/languageProcessing/researches/keywordCount.js"],"sourcesContent":["import { flatten, flattenDeep } from \"lodash\";\nimport getSentencesFromTree from \"../helpers/sentence/getSentencesFromTree\";\nimport { normalizeSingle } from \"../helpers/sanitize/quotes\";\nimport getMarkingsInSentence from \"../helpers/highlighting/getMarkingsInSentence\";\nimport matchWordFormsWithSentence from \"../helpers/match/matchWordFormsWithSentence\";\nimport isDoubleQuoted from \"../helpers/match/isDoubleQuoted\";\nimport { markWordsInASentence } from \"../helpers/word/markWordsInSentences\";\nimport getSentences from \"../helpers/sentence/getSentences\";\nimport { filterShortcodesFromHTML } from \"../helpers\";\n\n/**\n * Counts the occurrences of the keyphrase in the text and creates the Mark objects for the matches.\n *\n * @param {(Sentence|string)[]}\tsentences\t\t\tThe sentences to check.\n * @param {Array}\t\tkeyphraseForms\t\t\t\tThe keyphrase forms.\n * @param {string}\t\tlocale\t\t\t\t\t\tThe locale used in the analysis.\n * @param {function}\tmatchWordCustomHelper\t\tA custom helper to match words with a text.\n * @param {boolean}\t\tisExactMatchRequested\t\tWhether the exact matching is requested.\n * @param {function}\tcustomSplitIntoTokensHelper\tA custom helper to split sentences into tokens.\n *\n * @returns {{markings: Mark[], count: number}} The number of keyphrase occurrences in the text and the Mark objects of the matches.\n */\nexport function countKeyphraseInText( sentences, keyphraseForms, locale, matchWordCustomHelper,\n\t\t\t\t\t\t\t\t\t isExactMatchRequested, customSplitIntoTokensHelper ) {\n\tconst result = { count: 0, markings: [] };\n\n\tsentences.forEach( sentence => {\n\t\tconst matchesInSentence = keyphraseForms.map( wordForms => matchWordFormsWithSentence( sentence,\n\t\t\twordForms, locale, matchWordCustomHelper, isExactMatchRequested, customSplitIntoTokensHelper ) );\n\n\t\t// A sentence has at least one full-match of the keyphrase if each word occurs at least once.\n\t\tconst isEachWordFound = matchesInSentence.every( wordForms => wordForms.count > 0 );\n\n\t\tif ( isEachWordFound ) {\n\t\t\t/*\n\t\t\t * Retrieve all the occurrences' count of each word of the keyphrase and save it in an array.\n\t\t\t * matches: [ [ { matches: [\"red\"], count: 1 } ], [ { matches: [\"pandas\"], count: 2 } ] ]\n\t\t\t * counts: [ 1, 2 ]\n\t\t\t */\n\t\t\tconst counts = matchesInSentence.map( match => match.count );\n\t\t\t/*\n\t\t\t * The number of the full-match count is the lowest count of the occurrences.\n\t\t\t * counts: [ 1, 2 ]\n\t\t\t * totalMatchCount: 1\n\t\t\t *\n\t\t\t * From the example above, the full-match is 1, because one of the \"pandas\" occurrences is not accompanied by \"red\"\n\t\t\t * to be counted as a full-match.\n\t\t\t */\n\t\t\tconst totalMatchCount = Math.min( ...counts );\n\t\t\tconst foundWords = flattenDeep( matchesInSentence.map( match => match.matches ) );\n\n\t\t\tlet markings = [];\n\n\t\t\tif ( matchWordCustomHelper ) {\n\t\t\t\t// Currently, this check is only applicable for Japanese.\n\t\t\t\tmarkings = markWordsInASentence( sentence, foundWords, matchWordCustomHelper );\n\t\t\t} else {\n\t\t\t\tmarkings = getMarkingsInSentence( sentence, foundWords );\n\t\t\t}\n\n\t\t\tresult.count += totalMatchCount;\n\t\t\tresult.markings.push( markings );\n\t\t}\n\t} );\n\n\treturn result;\n}\n\n/**\n * Calculates the keyphrase count, takes morphology into account.\n *\n * @param {Paper} paper The paper containing keyphrase and text.\n * @param {Researcher} researcher The researcher.\n *\n * @returns {{count: number, markings: Mark[], keyphraseLength: number}} An object containing the keyphrase count, markings and the kephrase length.\n */\nexport default function getKeyphraseCount( paper, researcher ) {\n\tconst result = { count: 0, markings: [], keyphraseLength: 0 };\n\tconst topicForms = researcher.getResearch( \"morphology\" );\n\tlet keyphraseForms = topicForms.keyphraseForms;\n\tconst keyphraseLength = keyphraseForms.length;\n\n\t/*\n\t * Normalize single quotes so that word form with different type of single quotes can still be matched.\n\t * For example, \"key‛word\" should match \"key'word\".\n\t */\n\tkeyphraseForms = keyphraseForms.map( word => word.map( form => normalizeSingle( form ) ) );\n\n\tif ( keyphraseLength === 0 ) {\n\t\treturn result;\n\t}\n\n\tconst matchWordCustomHelper = researcher.getHelper( \"matchWordCustomHelper\" );\n\tconst customSentenceTokenizer = researcher.getHelper( \"memoizedTokenizer\" );\n\tconst customSplitIntoTokensHelper = researcher.getHelper( \"splitIntoTokensCustom\" );\n\tconst locale = paper.getLocale();\n\tconst text = matchWordCustomHelper\n\t\t? filterShortcodesFromHTML( paper.getText(), paper._attributes && paper._attributes.shortcodes )\n\t\t: paper.getText();\n\n\t// When the custom helper is available, we're using the sentences retrieved from the text for the analysis.\n\tconst sentences = matchWordCustomHelper ? getSentences( text, customSentenceTokenizer ) : getSentencesFromTree( paper );\n\t// Exact matching is requested when the keyphrase is enclosed in double quotes.\n\tconst isExactMatchRequested = isDoubleQuoted( paper.getKeyword() );\n\n\t/*\n\t* Count the amount of keyphrase occurrences in the sentences.\n\t* An occurrence is counted when all words of the keyphrase are contained within the sentence. Each sentence can contain multiple keyphrases.\n\t* (e.g. \"The apple potato is an apple and a potato.\" has two occurrences of the keyphrase \"apple potato\").\n\t*/\n\tconst keyphraseFound = countKeyphraseInText( sentences, keyphraseForms, locale, matchWordCustomHelper,\n\t\tisExactMatchRequested, customSplitIntoTokensHelper );\n\n\tresult.count = keyphraseFound.count;\n\tresult.markings = flatten( keyphraseFound.markings );\n\tresult.keyphraseLength = keyphraseLength;\n\n\treturn result;\n}\n\n/**\n * Calculates the keyphrase count, takes morphology into account.\n *\n * @deprecated Use getKeyphraseCount instead.\n *\n * @param {Paper} paper The paper containing keyphrase and text.\n * @param {Researcher} researcher The researcher.\n *\n * @returns {Object} An array of all the matches, markings and the keyphrase count.\n */\nexport function keywordCount( paper, researcher ) {\n\tconsole.warn( \"This function is deprecated, use getKeyphraseCount instead.\" );\n\treturn getKeyphraseCount( paper, researcher );\n}\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,WAAW,QAAQ,QAAQ;AAC7C,OAAOC,oBAAoB;AAC3B,SAASC,eAAe;AACxB,OAAOC,qBAAqB;AAC5B,OAAOC,0BAA0B;AACjC,OAAOC,cAAc;AACrB,SAASC,oBAAoB;AAC7B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B;EACA,MAAMrC,SAAS,GAAGG,qBAAqB,GAAGN,YAAY,CAAEuC,IAAI,EAAEF,uBAAwB,CAAC,GAAG3C,oBAAoB,CAAEkC,KAAM,CAAC;EACvH;EACA,MAAMrB,qBAAqB,GAAGT,cAAc,CAAE8B,KAAK,CAACe,UAAU,CAAC,CAAE,CAAC;;EAElE;AACD;AACA;AACA;AACA;EACC,MAAMC,cAAc,GAAG1C,oBAAoB,CAAEC,SAAS,EAAEC,cAAc,EAAEC,MAAM,EAAEC,qBAAqB,EACpGC,qBAAqB,EAAEC,2BAA4B,CAAC;EAErDC,MAAM,CAACC,KAAK,GAAGkC,cAAc,CAAClC,KAAK;EACnCD,MAAM,CAACE,QAAQ,GAAGnB,OAAO,CAAEoD,cAAc,CAACjC,QAAS,CAAC;EACpDF,MAAM,CAACqB,eAAe,GAAGA,eAAe;EAExC,OAAOrB,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASoC,YAAYA,CAAEjB,KAAK,EAAEC,UAAU,EAAG;EACjDiB,OAAO,CAACC,IAAI,CAAE,6DAA8D,CAAC;EAC7E,OAAOpB,iBAAiB,CAAEC,KAAK,EAAEC,UAAW,CAAC;AAC9C","ignoreList":[]}
1
+ {"version":3,"file":"keywordCount.js","names":["flatten","flattenDeep","getSentencesFromTree","normalizeSingle","getMarkingsInSentence","matchWordFormsWithSentence","isDoubleQuoted","markWordsInASentence","getSentences","filterShortcodesFromHTML","countKeyphraseInText","sentences","keyphraseForms","locale","matchWordCustomHelper","isExactMatchRequested","customSplitIntoTokensHelper","result","count","markings","forEach","sentence","matchesInSentence","map","wordForms","isEachWordFound","every","counts","match","totalMatchCount","Math","min","foundWords","matches","push","getKeyphraseCount","paper","researcher","keyphraseLength","topicForms","getResearch","length","word","form","getHelper","customSentenceTokenizer","getLocale","text","getText","_attributes","shortcodes","getKeyword","keyphraseFound","keywordCount","console","warn"],"sources":["../../../src/languageProcessing/researches/keywordCount.js"],"sourcesContent":["import {flatten, flattenDeep} from 'lodash';\nimport getSentencesFromTree from '../helpers/sentence/getSentencesFromTree';\nimport {normalizeSingle} from '../helpers/sanitize/quotes';\nimport getMarkingsInSentence from '../helpers/highlighting/getMarkingsInSentence';\nimport matchWordFormsWithSentence from '../helpers/match/matchWordFormsWithSentence';\nimport isDoubleQuoted from '../helpers/match/isDoubleQuoted';\nimport {markWordsInASentence} from '../helpers/word/markWordsInSentences';\nimport getSentences from '../helpers/sentence/getSentences';\nimport {filterShortcodesFromHTML} from '../helpers';\n\n/**\n * Counts the occurrences of the keyphrase in the text and creates the Mark objects for the matches.\n *\n * @param {(Sentence|string)[]}\tsentences\t\t\tThe sentences to check.\n * @param {Array}\t\tkeyphraseForms\t\t\t\tThe keyphrase forms.\n * @param {string}\t\tlocale\t\t\t\t\t\tThe locale used in the analysis.\n * @param {function}\tmatchWordCustomHelper\t\tA custom helper to match words with a text.\n * @param {boolean}\t\tisExactMatchRequested\t\tWhether the exact matching is requested.\n * @param {function}\tcustomSplitIntoTokensHelper\tA custom helper to split sentences into tokens.\n *\n * @returns {{markings: Mark[], count: number}} The number of keyphrase occurrences in the text and the Mark objects of the matches.\n */\nexport function countKeyphraseInText(\n sentences,\n keyphraseForms,\n locale,\n matchWordCustomHelper,\n isExactMatchRequested,\n customSplitIntoTokensHelper\n) {\n const result = {count: 0, markings: []};\n\n sentences.forEach(sentence => {\n const matchesInSentence = keyphraseForms.map(wordForms =>\n matchWordFormsWithSentence(\n sentence,\n wordForms,\n locale,\n matchWordCustomHelper,\n isExactMatchRequested,\n customSplitIntoTokensHelper\n )\n );\n // A sentence has at least one full-match of the keyphrase if each word occurs at least once.\n const isEachWordFound = matchesInSentence.every(wordForms => wordForms.count > 0);\n\n if (isEachWordFound) {\n /*\n * Retrieve all the occurrences' count of each word of the keyphrase and save it in an array.\n * matches: [ [ { matches: [\"red\"], count: 1 } ], [ { matches: [\"pandas\"], count: 2 } ] ]\n * counts: [ 1, 2 ]\n */\n const counts = matchesInSentence.map(match => match.count);\n /*\n * The number of the full-match count is the lowest count of the occurrences.\n * counts: [ 1, 2 ]\n * totalMatchCount: 1\n *\n * From the example above, the full-match is 1, because one of the \"pandas\" occurrences is not accompanied by \"red\"\n * to be counted as a full-match.\n */\n const totalMatchCount = Math.min(...counts);\n const foundWords = flattenDeep(matchesInSentence.map(match => match.matches));\n\n let markings = [];\n\n if (matchWordCustomHelper) {\n // Currently, this check is only applicable for Japanese.\n markings = markWordsInASentence(sentence, foundWords, matchWordCustomHelper);\n } else {\n markings = getMarkingsInSentence(sentence, foundWords);\n }\n\n result.count += totalMatchCount;\n result.markings.push(markings);\n }\n });\n\n return result;\n}\n\n/**\n * Calculates the keyphrase count, takes morphology into account.\n *\n * @param {Paper} paper The paper containing keyphrase and text.\n * @param {Researcher} researcher The researcher.\n *\n * @returns {{count: number, markings: Mark[], keyphraseLength: number}} An object containing the keyphrase count, markings and the kephrase length.\n */\nexport default function getKeyphraseCount(paper, researcher) {\n const result = {count: 0, markings: [], keyphraseLength: 0};\n const topicForms = researcher.getResearch('morphology');\n let keyphraseForms = topicForms.keyphraseForms;\n const keyphraseLength = keyphraseForms.length;\n\n /*\n * Normalize single quotes so that word form with different type of single quotes can still be matched.\n * For example, \"key‛word\" should match \"key'word\".\n */\n keyphraseForms = keyphraseForms.map(word => word.map(form => normalizeSingle(form)));\n\n if (keyphraseLength === 0) {\n return result;\n }\n\n const matchWordCustomHelper = researcher.getHelper('matchWordCustomHelper');\n const customSentenceTokenizer = researcher.getHelper('memoizedTokenizer');\n const customSplitIntoTokensHelper = researcher.getHelper('splitIntoTokensCustom');\n const locale = paper.getLocale();\n const text = matchWordCustomHelper\n ? filterShortcodesFromHTML(paper.getText(), paper._attributes && paper._attributes.shortcodes)\n : paper.getText();\n\n // When the custom helper is available, we're using the sentences retrieved from the text for the analysis.\n const sentences = matchWordCustomHelper\n ? getSentences(text, customSentenceTokenizer)\n : getSentencesFromTree(paper);\n // Exact matching is requested when the keyphrase is enclosed in double quotes.\n const isExactMatchRequested = isDoubleQuoted(paper.getKeyword());\n\n /*\n * Count the amount of keyphrase occurrences in the sentences.\n * An occurrence is counted when all words of the keyphrase are contained within the sentence. Each sentence can contain multiple keyphrases.\n * (e.g. \"The apple potato is an apple and a potato.\" has two occurrences of the keyphrase \"apple potato\").\n */\n const keyphraseFound = countKeyphraseInText(\n sentences,\n keyphraseForms,\n locale,\n matchWordCustomHelper,\n isExactMatchRequested,\n customSplitIntoTokensHelper\n );\n\n result.count = keyphraseFound.count;\n result.markings = flatten(keyphraseFound.markings);\n result.keyphraseLength = keyphraseLength;\n\n return result;\n}\n\n/**\n * Calculates the keyphrase count, takes morphology into account.\n *\n * @deprecated Use getKeyphraseCount instead.\n *\n * @param {Paper} paper The paper containing keyphrase and text.\n * @param {Researcher} researcher The researcher.\n *\n * @returns {Object} An array of all the matches, markings and the keyphrase count.\n */\nexport function keywordCount(paper, researcher) {\n console.warn('This function is deprecated, use getKeyphraseCount instead.');\n return getKeyphraseCount(paper, researcher);\n}\n"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,WAAW,QAAO,QAAQ;AAC3C,OAAOC,oBAAoB;AAC3B,SAAQC,eAAe;AACvB,OAAOC,qBAAqB;AAC5B,OAAOC,0BAA0B;AACjC,OAAOC,cAAc;AACrB,SAAQC,oBAAoB;AAC5B,OAAOC,YAAY;AACnB,SAAQC,wBAAwB;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClCC,SAAS,EACTC,cAAc,EACdC,MAAM,EACNC,qBAAqB,EACrBC,qBAAqB,EACrBC,2BAA2B,EAC3B;EACA,MAAMC,MAAM,GAAG;IAACC,KAAK,EAAE,CAAC;IAAEC,QAAQ,EAAE;EAAE,CAAC;EAEvCR,SAAS,CAACS,OAAO,CAACC,QAAQ,IAAI;IAC5B,MAAMC,iBAAiB,GAAGV,cAAc,CAACW,GAAG,CAACC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E,QAAQ,GAAGnB,OAAO,CAACoD,cAAc,CAACjC,QAAQ,CAAC;EAClDF,MAAM,CAACqB,eAAe,GAAGA,eAAe;EAExC,OAAOrB,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASoC,YAAYA,CAACjB,KAAK,EAAEC,UAAU,EAAE;EAC9CiB,OAAO,CAACC,IAAI,CAAC,6DAA6D,CAAC;EAC3E,OAAOpB,iBAAiB,CAACC,KAAK,EAAEC,UAAU,CAAC;AAC7C","ignoreList":[]}
@@ -74,19 +74,20 @@ export default class ParagraphTooLongAssessment extends Assessment {
74
74
  config,
75
75
  i18n
76
76
  }) {
77
- let status = '';
77
+ let status = 'bad';
78
78
  if (paragraphsLength.length === 0) {
79
79
  status = 'good';
80
- }
81
- const longestParagraphLength = paragraphsLength[0].countLength;
82
- if (longestParagraphLength <= config.parameters.recommendedLength) {
83
- status = 'good';
84
- }
85
- if (inRange(longestParagraphLength, config.parameters.recommendedLength, config.parameters.maximumRecommendedLength)) {
86
- status = 'good';
87
- }
88
- if (longestParagraphLength > config.parameters.maximumRecommendedLength) {
89
- status = 'bad';
80
+ } else {
81
+ const longestParagraphLength = paragraphsLength[0].countLength;
82
+ if (longestParagraphLength <= config.parameters.recommendedLength) {
83
+ status = 'good';
84
+ }
85
+ if (inRange(longestParagraphLength, config.parameters.recommendedLength, config.parameters.maximumRecommendedLength)) {
86
+ status = 'good';
87
+ }
88
+ if (longestParagraphLength > config.parameters.maximumRecommendedLength) {
89
+ status = 'bad';
90
+ }
90
91
  }
91
92
  const score = this.getScore(this._config.priority, status);
92
93
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"ParagraphTooLongAssessment.js","names":["merge","React","Text","inRangeEndInclusive","inRange","AssessmentResult","Assessment","ParagraphTooLongAssessment","constructor","config","defaultConfig","id","priority","docUrl","fixPosition","ctaType","parameters","recommendedLength","maximumRecommendedLength","title","content","bad","improve","good","identifier","_config","getConfig","researcher","currentConfig","languageSpecificConfig","_isProduct","productPageParams","defaultPageParams","calculateResult","paragraphsLength","i18n","status","length","longestParagraphLength","countLength","score","getScore","body","createElement","as","href","target","rel","translate","sortParagraphs","paragraphs","sort","a","b","getResult","paper","getResearch","paragraphLengthResult","assessmentResult","setScore","setStatus","setBody","isApplicable","hasEnoughContentForAssessment"],"sources":["../../../../src/scoring/assessments/readability/ParagraphTooLongAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\nimport {inRangeEndInclusive as inRange} from '../../helpers/assessments/inRange';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\n\n/**\n * Represents the assessment that will look if the text has too long paragraphs.\n */\nexport default class ParagraphTooLongAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {object} config The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'textParagraphTooLong',\n priority: 'high',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#paragraph-length',\n fixPosition: 'longParagraph',\n ctaType: 'fix',\n parameters: {\n recommendedLength: 150,\n maximumRecommendedLength: 150\n },\n title: 'Paragraph length',\n content: {\n bad: 'Paragraph too long. Keep paragraph length less than 150 words for readability.',\n improve: '',\n good: 'Paragraph is optimized, with less than 150 words.'\n }\n };\n\n this.identifier = 'textParagraphTooLong';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Check if there is language-specific config, and if so, overwrite the current config with it.\n *\n * @param {Researcher} researcher The researcher to use.\n *\n * @returns {Object} The config that should be used.\n */\n getConfig(researcher) {\n const currentConfig = this._config;\n const languageSpecificConfig = researcher.getConfig('paragraphLength');\n\n /*\n * If a language has a specific paragraph length config, check further if the assessment is run in product pages.\n * If it's run in product pages, override the default config parameters with the language specific config for product pages,\n * otherwise override it with the language specific config for default pages analysis.\n */\n if (languageSpecificConfig) {\n currentConfig.parameters = this._isProduct\n ? languageSpecificConfig.productPageParams\n : languageSpecificConfig.defaultPageParams;\n }\n\n return currentConfig;\n }\n\n /**\n *\n * @param paragraphsLength\n * @param tooLongParagraphs\n * @param config\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult({paragraphsLength, config, i18n}) {\n let status = '';\n if (paragraphsLength.length === 0) {\n status = 'good';\n }\n\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 const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </a>\n )}\n </Text>\n )\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,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,QAAO,kBAAkB;AACrC,SAAQC,mBAAmB,IAAIC,OAAO;AACtC,OAAOC,gBAAgB;AACvB,OAAOC,UAAU;;AAEjB;AACA;AACA;AACA,eAAe,MAAMC,0BAA0B,SAASD,UAAU,CAAC;EACjE;AACF;AACA;AACA;AACA;AACA;AACA;EACEE,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,sBAAsB;MAC1BC,QAAQ,EAAE,MAAM;MAChBC,MAAM,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,GAAG,sBAAsB;IACxC,IAAI,CAACC,OAAO,GAAGzB,KAAK,CAACU,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,MAAMI,sBAAsB,GAAGF,UAAU,CAACD,SAAS,CAAC,iBAAiB,CAA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CAACR,KAAK,CAAC;EAClD;AACF","ignoreList":[]}
1
+ {"version":3,"file":"ParagraphTooLongAssessment.js","names":["merge","React","Text","inRangeEndInclusive","inRange","AssessmentResult","Assessment","ParagraphTooLongAssessment","constructor","config","defaultConfig","id","priority","docUrl","fixPosition","ctaType","parameters","recommendedLength","maximumRecommendedLength","title","content","bad","improve","good","identifier","_config","getConfig","researcher","currentConfig","languageSpecificConfig","_isProduct","productPageParams","defaultPageParams","calculateResult","paragraphsLength","i18n","status","length","longestParagraphLength","countLength","score","getScore","body","createElement","as","href","target","rel","translate","sortParagraphs","paragraphs","sort","a","b","getResult","paper","getResearch","paragraphLengthResult","assessmentResult","setScore","setStatus","setBody","isApplicable","hasEnoughContentForAssessment"],"sources":["../../../../src/scoring/assessments/readability/ParagraphTooLongAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\nimport {inRangeEndInclusive as inRange} from '../../helpers/assessments/inRange';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\n\n/**\n * Represents the assessment that will look if the text has too long paragraphs.\n */\nexport default class ParagraphTooLongAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {object} config The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'textParagraphTooLong',\n priority: 'high',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#paragraph-length',\n fixPosition: 'longParagraph',\n ctaType: 'fix',\n parameters: {\n recommendedLength: 150,\n maximumRecommendedLength: 150\n },\n title: 'Paragraph length',\n content: {\n bad: 'Paragraph too long. Keep paragraph length less than 150 words for readability.',\n improve: '',\n good: 'Paragraph is optimized, with less than 150 words.'\n }\n };\n\n this.identifier = 'textParagraphTooLong';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Check if there is language-specific config, and if so, overwrite the current config with it.\n *\n * @param {Researcher} researcher The researcher to use.\n *\n * @returns {Object} The config that should be used.\n */\n getConfig(researcher) {\n const currentConfig = this._config;\n const languageSpecificConfig = researcher.getConfig('paragraphLength');\n\n /*\n * If a language has a specific paragraph length config, check further if the assessment is run in product pages.\n * If it's run in product pages, override the default config parameters with the language specific config for product pages,\n * otherwise override it with the language specific config for default pages analysis.\n */\n if (languageSpecificConfig) {\n currentConfig.parameters = this._isProduct\n ? languageSpecificConfig.productPageParams\n : languageSpecificConfig.defaultPageParams;\n }\n\n return currentConfig;\n }\n\n /**\n *\n * @param paragraphsLength\n * @param tooLongParagraphs\n * @param config\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult({paragraphsLength, config, i18n}) {\n let status = 'bad';\n if (paragraphsLength.length === 0) {\n status = 'good';\n } else {\n const longestParagraphLength = paragraphsLength[0].countLength;\n\n if (longestParagraphLength <= config.parameters.recommendedLength) {\n status = 'good';\n }\n\n if (\n inRange(\n longestParagraphLength,\n config.parameters.recommendedLength,\n config.parameters.maximumRecommendedLength\n )\n ) {\n status = 'good';\n }\n\n if (longestParagraphLength > config.parameters.maximumRecommendedLength) {\n status = 'bad';\n }\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </a>\n )}\n </Text>\n )\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,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,QAAO,kBAAkB;AACrC,SAAQC,mBAAmB,IAAIC,OAAO;AACtC,OAAOC,gBAAgB;AACvB,OAAOC,UAAU;;AAEjB;AACA;AACA;AACA,eAAe,MAAMC,0BAA0B,SAASD,UAAU,CAAC;EACjE;AACF;AACA;AACA;AACA;AACA;AACA;EACEE,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,sBAAsB;MAC1BC,QAAQ,EAAE,MAAM;MAChBC,MAAM,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,GAAG,sBAAsB;IACxC,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CAAC;IACtDkB,gBAAgB,CAACE,SAAS,CAACH,qBAAqB,CAACrB,MAAM,CAAC;IACxDsB,gBAAgB,CAACG,OAAO,CAACJ,qBAAqB,CAACf,IAAI,CAAC;IAEpD,OAAOgB,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEI,YAAYA,CAACP,KAAK,EAAE;IAClB,OAAO,IAAI,CAACQ,6BAA6B,CAACR,KAAK,CAAC;EAClD;AACF","ignoreList":[]}
@@ -79,8 +79,8 @@ class IntroductionKeywordAssessment extends Assessment {
79
79
  * @returns {Object} result object with a score and translation text.
80
80
  */
81
81
  calculateResult(i18n) {
82
- let status = '';
83
- if (this._firstParagraphMatches.foundInOneSentence) {
82
+ let status = 'bad';
83
+ if (this._firstParagraphMatches.foundInOneSentence || this._firstParagraphMatches.foundInParagraph) {
84
84
  status = 'good';
85
85
  } else {
86
86
  status = 'bad';
@@ -1 +1 @@
1
- {"version":3,"file":"IntroductionKeywordAssessment.js","names":["merge","Assessment","AssessmentResult","KeyIcon","React","Text","IntroductionKeywordAssessment","constructor","config","defaultConfig","id","ctaType","priority","docUrl","fixPosition","icon","title","content","improve","bad","good","identifier","_config","getResult","paper","researcher","i18n","assessmentResult","_firstParagraphMatches","getResearch","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","isApplicable","hasKeyword","hasText","foundInOneSentence","getScore","createElement","as","href","target","rel","translate"],"sources":["../../../../src/scoring/assessments/seo/IntroductionKeywordAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\n\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport {KeyIcon} from '@shopify/polaris-icons';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\n\n/**\n * Assessment to check whether the keyphrase or synonyms are encountered in the first paragraph of the article.\n */\nclass IntroductionKeywordAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {Object} [config] The configuration to use.\n * @param {string} [config.url] The URL to the relevant article on Yoast.com.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'introductionKeyword',\n ctaType: 'fix',\n priority: 'low',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#keyword-in-introduction',\n fixPosition: 'highlightFirstParagraph',\n icon: KeyIcon,\n title: 'Introduction Keyword',\n content: {\n improve: '',\n bad: 'No keywords found in the first sentence. Add one to improve keyword rank.',\n good: 'Keyword is included in the first sentence.'\n }\n };\n\n this.identifier = 'introductionKeyword';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Assesses the presence of keyphrase or synonyms in the first paragraph.\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 result of this assessment.\n */\n getResult({paper, researcher, i18n}) {\n const assessmentResult = new AssessmentResult({config: this._config});\n\n this._firstParagraphMatches = researcher.getResearch('findKeywordInFirstParagraph');\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 if the paper has both keyword and text.\n *\n * @param {Paper} paper The paper to be analyzed.\n *\n * @returns {boolean} Whether the assessment is applicable or not.\n */\n isApplicable(paper) {\n return paper.hasKeyword() && paper.hasText();\n }\n\n /**\n * Returns a result based on the number of occurrences of keyphrase in the first paragraph.\n *\n * @returns {Object} result object with a score and translation text.\n */\n calculateResult(i18n) {\n let status = '';\n\n if (this._firstParagraphMatches.foundInOneSentence) {\n status = 'good';\n } else {\n status = 'bad';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </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CAACG,KAAK,CAAC;IACjDN,gBAAgB,CAACO,SAAS,CAACJ,gBAAgB,CAACK,MAAM,CAAC;IACnDR,gBAAgB,CAACS,OAAO,CAACN,gBAAgB,CAACO,IAAI,CAAC;IAE/C,OAAOV,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEW,YAAYA,CAACd,KAAK,EAAE;IAClB,OAAOA,KAAK,CAACe,UAAU,CAAC,CAAC,IAAIf,KAAK,CAACgB,OAAO,CAAC,CAAC;EAC9C;;EAEA;AACF;AACA;AACA;AACA;EACET,eAAeA,CAACL,IAAI,EAAE;IACpB,IAAIS,MAAM,GAAG,EAAE;IAEf,IAAI,IAAI,CAACP,sBAAsB,CAACa,kBAAkB,EAAE;MAClDN,MAAM,GAAG,MAAM;IACjB,CAAC,MAAM;MACLA,MAAM,GAAG,KAAK;IAChB;IAEA,MAAMF,KAAK,GAAG,IAAI,CAACS,QAAQ,CAAC,IAAI,CAACpB,OAAO,CAACV,QAAQ,EAAEuB,MAAM,CAAC;IAE1D,OAAO;MACLF,KAAK;MACLE,MAAM;MACNE,IAAI,eACFjC,KAAA,CAAAuC,aAAA,CAACtC,IAAI;QAACuC,EAAE,EAAE;MAAO,GACd,IAAI,CAACtB,OAAO,CAACL,OAAO,CAACkB,MAAM,CAAC,EAAE,GAAG,EACjC,IAAI,CAACb,OAAO,CAACT,MAAM,iBAClBT,KAAA,CAAAuC,aAAA;QAAGE,IAAI,EAAE,IAAI,CAACvB,OAAO,CAACT,MAAO;QAACiC,MAAM,EAAC,QAAQ;QAACC,GAAG,EAAC;MAAY,GAC3DrB,IAAI,GAAGA,IAAI,CAACsB,SAAS,CAAC,yBAAyB,CAAC,GAAG,YACnD,CAED;IAEV,CAAC;EACH;AACF;AAEA,eAAe1C,6BAA6B","ignoreList":[]}
1
+ {"version":3,"file":"IntroductionKeywordAssessment.js","names":["merge","Assessment","AssessmentResult","KeyIcon","React","Text","IntroductionKeywordAssessment","constructor","config","defaultConfig","id","ctaType","priority","docUrl","fixPosition","icon","title","content","improve","bad","good","identifier","_config","getResult","paper","researcher","i18n","assessmentResult","_firstParagraphMatches","getResearch","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","isApplicable","hasKeyword","hasText","foundInOneSentence","foundInParagraph","getScore","createElement","as","href","target","rel","translate"],"sources":["../../../../src/scoring/assessments/seo/IntroductionKeywordAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\n\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport {KeyIcon} from '@shopify/polaris-icons';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\n\n/**\n * Assessment to check whether the keyphrase or synonyms are encountered in the first paragraph of the article.\n */\nclass IntroductionKeywordAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {Object} [config] The configuration to use.\n * @param {string} [config.url] The URL to the relevant article on Yoast.com.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'introductionKeyword',\n ctaType: 'fix',\n priority: 'low',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#keyword-in-introduction',\n fixPosition: 'highlightFirstParagraph',\n icon: KeyIcon,\n title: 'Introduction Keyword',\n content: {\n improve: '',\n bad: 'No keywords found in the first sentence. Add one to improve keyword rank.',\n good: 'Keyword is included in the first sentence.'\n }\n };\n\n this.identifier = 'introductionKeyword';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Assesses the presence of keyphrase or synonyms in the first paragraph.\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 result of this assessment.\n */\n getResult({paper, researcher, i18n}) {\n const assessmentResult = new AssessmentResult({config: this._config});\n\n this._firstParagraphMatches = researcher.getResearch('findKeywordInFirstParagraph');\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 if the paper has both keyword and text.\n *\n * @param {Paper} paper The paper to be analyzed.\n *\n * @returns {boolean} Whether the assessment is applicable or not.\n */\n isApplicable(paper) {\n return paper.hasKeyword() && paper.hasText();\n }\n\n /**\n * Returns a result based on the number of occurrences of keyphrase in the first paragraph.\n *\n * @returns {Object} result object with a score and translation text.\n */\n calculateResult(i18n) {\n let status = 'bad';\n\n if (\n this._firstParagraphMatches.foundInOneSentence ||\n this._firstParagraphMatches.foundInParagraph\n ) {\n status = 'good';\n } else {\n status = 'bad';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </a>\n )}\n </Text>\n )\n };\n }\n}\n\nexport default IntroductionKeywordAssessment;\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAE5B,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AACvB,SAAQC,OAAO,QAAO,wBAAwB;AAC9C,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,QAAO,kBAAkB;;AAErC;AACA;AACA;AACA,MAAMC,6BAA6B,SAASL,UAAU,CAAC;EACrD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEM,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,qBAAqB;MACzBC,OAAO,EAAE,KAAK;MACdC,QAAQ,EAAE,KAAK;MACfC,MAAM,EACJ,qGAAqG;MACvGC,WAAW,EAAE,yBAAyB;MACtCC,IAAI,EAAEZ,OAAO;MACba,KAAK,EAAE,sBAAsB;MAC7BC,OAAO,EAA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AACrB,OAAO,CAACV,QAAQ,EAAEuB,MAAM,CAAC;IAE1D,OAAO;MACLF,KAAK;MACLE,MAAM;MACNE,IAAI,eACFjC,KAAA,CAAAwC,aAAA,CAACvC,IAAI;QAACwC,EAAE,EAAE;MAAO,GACd,IAAI,CAACvB,OAAO,CAACL,OAAO,CAACkB,MAAM,CAAC,EAAE,GAAG,EACjC,IAAI,CAACb,OAAO,CAACT,MAAM,iBAClBT,KAAA,CAAAwC,aAAA;QAAGE,IAAI,EAAE,IAAI,CAACxB,OAAO,CAACT,MAAO;QAACkC,MAAM,EAAC,QAAQ;QAACC,GAAG,EAAC;MAAY,GAC3DtB,IAAI,GAAGA,IAAI,CAACuB,SAAS,CAAC,yBAAyB,CAAC,GAAG,YACnD,CAED;IAEV,CAAC;EACH;AACF;AAEA,eAAe3C,6BAA6B","ignoreList":[]}
@@ -3,7 +3,6 @@ import React from 'react';
3
3
  import { Text } from '@shopify/polaris';
4
4
  import Assessment from "../assessment";
5
5
  import AssessmentResult from "../../../values/AssessmentResult";
6
- import { calculateKeywordDensity } from "../../../helpers";
7
6
  import keyphraseLengthFactor from "../../../scoring/helpers/assessments/keyphraseLengthFactor";
8
7
 
9
8
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"KeywordDensityAssessment.js","names":["merge","React","Text","Assessment","AssessmentResult","calculateKeywordDensity","keyphraseLengthFactor","KeyphraseDensityAssessment","constructor","config","defaultConfig","id","fixPosition","docUrl","ctaType","priority","title","content","good","bad","improve","identifier","_config","getResult","paper","researcher","i18n","_keyphraseCount","getResearch","keyphraseLength","_keyphraseDensity","assessmentResult","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","setTitle","density","roundedDensity","parseFloat","toFixed","getScore","createElement","as","href","target","rel","translate","isApplicable","hasText","hasKeyword"],"sources":["../../../../src/scoring/assessments/seo/KeywordDensityAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\n\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\n\nimport {calculateKeywordDensity} from '../../../helpers';\nimport keyphraseLengthFactor from '../../../scoring/helpers/assessments/keyphraseLengthFactor';\n\n/**\n * Represents the assessment that will look if the keyphrase density is within the recommended range.\n */\nclass KeyphraseDensityAssessment extends Assessment {\n /**\n *\n * @param config\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'keyphraseDensity',\n fixPosition: 'highlightKeyword',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#main-keyword-density',\n ctaType: 'fix',\n priority: 'high',\n title: 'Main keyword density',\n content: {\n good: 'Keyword density is optimized, between 1 - 1.5%.',\n bad: 'Keep keyword density from 1% - 1.5%.',\n improve: ''\n }\n };\n\n this.identifier = 'keyphraseDensity';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Runs the keyphrase density module, based on this returns an assessment\n * result with score.\n *\n * @param {Paper} paper The paper to use for the assessment.\n * @param {Researcher} researcher The researcher used for calling the research.\n *\n * @param i18n\n * @returns {AssessmentResult} The result of the assessment.\n */\n getResult({paper, researcher, i18n}) {\n this._keyphraseCount = researcher.getResearch('getKeyphraseCount');\n const keyphraseLength = this._keyphraseCount.keyphraseLength;\n\n this._keyphraseDensity = researcher.getResearch('getKeyphraseDensity');\n\n this._keyphraseDensity = this._keyphraseDensity * keyphraseLengthFactor(keyphraseLength);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n const calculatedResult = this.calculateResult(paper, i18n);\n\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n assessmentResult.setTitle(calculatedResult.title);\n return assessmentResult;\n }\n\n /**\n * Returns the score for the keyphrase density.\n *\n * @returns {Object} The object with calculated score and resultText.\n */\n calculateResult(paper, i18n) {\n const density = this._keyphraseDensity;\n const roundedDensity = parseFloat(density.toFixed(2));\n\n let status = '';\n if (roundedDensity >= 1 && roundedDensity <= 1.5) {\n status = 'good';\n } else {\n status = 'bad';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n title: (this._config.title || 'Main keyword density') + ': ' + roundedDensity + '%',\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n * Checks whether the paper has a text of the minimum required length and a keyphrase is set. Language-specific length requirements and methods\n * of counting text length may apply (e.g. for Japanese, the text should be counted in characters instead of words, which also makes the minimum\n * required length higher).\n *\n * @param {Paper} \t\tpaper \t\tThe paper to use for the assessment.\n * @param {Researcher} researcher The paper to use for the assessment.\n *\n * @returns {boolean} True if applicable.\n */\n isApplicable(paper, researcher) {\n return paper.hasText() && paper.hasKeyword();\n }\n}\n\nexport default KeyphraseDensityAssessment;\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,QAAO,kBAAkB;AAErC,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AAEvB,SAAQC,uBAAuB;AAC/B,OAAOC,qBAAqB;;AAE5B;AACA;AACA;AACA,MAAMC,0BAA0B,SAASJ,UAAU,CAAC;EAClD;AACF;AACA;AACA;EACEK,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,kBAAkB;MACtBC,WAAW,EAAE,kBAAkB;MAC/BC,MAAM,EACJ,kGAAkG;MACpGC,OAAO,EAAE,KAAK;MACdC,QAAQ,EAAE,MAAM;MAChBC,KAAK,EAAE,sBAAsB;MAC7BC,OAAO,EAAE;QACPC,IAAI,EAAE,iDAAiD;QACvDC,GAAG,EAAE,sCAAsC;QAC3CC,OAAO,EAA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cAAc,IAAI,CAAC,IAAIA,cAAc,IAAI,GAAG,EAAE;MAChDL,MAAM,GAAG,MAAM;IACjB,CAAC,MAAM;MACLA,MAAM,GAAG,KAAK;IAChB;IAEA,MAAMF,KAAK,GAAG,IAAI,CAACU,QAAQ,CAAC,IAAI,CAACvB,OAAO,CAACP,QAAQ,EAAEsB,MAAM,CAAC;IAE1D,OAAO;MACLrB,KAAK,EAAE,CAAC,IAAI,CAACM,OAAO,CAACN,KAAK,IAAI,sBAAsB,IAAI,IAAI,GAAG0B,cAAc,GAAG,GAAG;MACnFP,KAAK;MACLE,MAAM;MACNE,IAAI,eACFtC,KAAA,CAAA6C,aAAA,CAAC5C,IAAI;QAAC6C,EAAE,EAAE;MAAO,GACd,IAAI,CAACzB,OAAO,CAACL,OAAO,CAACoB,MAAM,CAAC,EAAE,GAAG,EACjC,IAAI,CAACf,OAAO,CAACT,MAAM,iBAClBZ,KAAA,CAAA6C,aAAA;QAAGE,IAAI,EAAE,IAAI,CAAC1B,OAAO,CAACT,MAAO;QAACoC,MAAM,EAAC,QAAQ;QAACC,GAAG,EAAC;MAAY,GAC3DxB,IAAI,GAAGA,IAAI,CAACyB,SAAS,CAAC,yBAAyB,CAAC,GAAG,YACnD,CAED;IAEV,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,YAAYA,CAAC5B,KAAK,EAAEC,UAAU,EAAE;IAC9B,OAAOD,KAAK,CAAC6B,OAAO,CAAC,CAAC,IAAI7B,KAAK,CAAC8B,UAAU,CAAC,CAAC;EAC9C;AACF;AAEA,eAAe/C,0BAA0B","ignoreList":[]}
1
+ {"version":3,"file":"KeywordDensityAssessment.js","names":["merge","React","Text","Assessment","AssessmentResult","keyphraseLengthFactor","KeyphraseDensityAssessment","constructor","config","defaultConfig","id","fixPosition","docUrl","ctaType","priority","title","content","good","bad","improve","identifier","_config","getResult","paper","researcher","i18n","_keyphraseCount","getResearch","keyphraseLength","_keyphraseDensity","assessmentResult","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","setTitle","density","roundedDensity","parseFloat","toFixed","getScore","createElement","as","href","target","rel","translate","isApplicable","hasText","hasKeyword"],"sources":["../../../../src/scoring/assessments/seo/KeywordDensityAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\n\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\n\nimport keyphraseLengthFactor from '../../../scoring/helpers/assessments/keyphraseLengthFactor';\n\n/**\n * Represents the assessment that will look if the keyphrase density is within the recommended range.\n */\nclass KeyphraseDensityAssessment extends Assessment {\n /**\n *\n * @param config\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'keyphraseDensity',\n fixPosition: 'highlightKeyword',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#main-keyword-density',\n ctaType: 'fix',\n priority: 'high',\n title: 'Main keyword density',\n content: {\n good: 'Keyword density is optimized, between 1 - 1.5%.',\n bad: 'Keep keyword density from 1% - 1.5%.',\n improve: ''\n }\n };\n\n this.identifier = 'keyphraseDensity';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Runs the keyphrase density module, based on this returns an assessment\n * result with score.\n *\n * @param {Paper} paper The paper to use for the assessment.\n * @param {Researcher} researcher The researcher used for calling the research.\n *\n * @param i18n\n * @returns {AssessmentResult} The result of the assessment.\n */\n getResult({paper, researcher, i18n}) {\n this._keyphraseCount = researcher.getResearch('getKeyphraseCount');\n const keyphraseLength = this._keyphraseCount.keyphraseLength;\n\n this._keyphraseDensity = researcher.getResearch('getKeyphraseDensity');\n\n this._keyphraseDensity = this._keyphraseDensity * keyphraseLengthFactor(keyphraseLength);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n const calculatedResult = this.calculateResult(paper, i18n);\n\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n assessmentResult.setTitle(calculatedResult.title);\n return assessmentResult;\n }\n\n /**\n * Returns the score for the keyphrase density.\n *\n * @returns {Object} The object with calculated score and resultText.\n */\n calculateResult(paper, i18n) {\n const density = this._keyphraseDensity;\n const roundedDensity = parseFloat(density.toFixed(2));\n\n let status = '';\n if (roundedDensity >= 1 && roundedDensity <= 1.5) {\n status = 'good';\n } else {\n status = 'bad';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n title: (this._config.title || 'Main keyword density') + ': ' + roundedDensity + '%',\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n * Checks whether the paper has a text of the minimum required length and a keyphrase is set. Language-specific length requirements and methods\n * of counting text length may apply (e.g. for Japanese, the text should be counted in characters instead of words, which also makes the minimum\n * required length higher).\n *\n * @param {Paper} \t\tpaper \t\tThe paper to use for the assessment.\n * @param {Researcher} researcher The paper to use for the assessment.\n *\n * @returns {boolean} True if applicable.\n */\n isApplicable(paper, researcher) {\n return paper.hasText() && paper.hasKeyword();\n }\n}\n\nexport default KeyphraseDensityAssessment;\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,QAAO,kBAAkB;AAErC,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AAEvB,OAAOC,qBAAqB;;AAE5B;AACA;AACA;AACA,MAAMC,0BAA0B,SAASH,UAAU,CAAC;EAClD;AACF;AACA;AACA;EACEI,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,kBAAkB;MACtBC,WAAW,EAAE,kBAAkB;MAC/BC,M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escriptionKeywordAssessment extends Assessment {
55
55
  researcher,
56
56
  i18n
57
57
  }) {
58
+ this._keyphraseCounts = researcher.getResearch('metaDescriptionKeyword');
58
59
  const assessmentResult = new AssessmentResult({
59
60
  config: this._config
60
61
  });
@@ -71,13 +72,8 @@ class MetaDescriptionKeywordAssessment extends Assessment {
71
72
  * @returns {Object} Result object with score and text.
72
73
  */
73
74
  calculateResult(paper, i18n) {
74
- const keyword = paper.getKeyword();
75
- const description = paper.getDescription();
76
- const {
77
- count
78
- } = matchTextWithWord(description, keyword, paper.getLocale(), null);
79
75
  let status = '';
80
- if (isNumber(count) && count > 0) {
76
+ if (this._keyphraseCounts > 0) {
81
77
  status = 'good';
82
78
  } else {
83
79
  status = 'bad';
@@ -1 +1 @@
1
- {"version":3,"file":"MetaDescriptionKeywordAssessment.js","names":["React","Text","isNumber","merge","Assessment","AssessmentResult","KeyIcon","matchTextWithWord","MetaDescriptionKeywordAssessment","constructor","config","defaultConfig","id","priority","fixPosition","ctaType","docUrl","icon","title","content","bad","good","improve","identifier","_config","getResult","paper","researcher","i18n","assessmentResult","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","keyword","getKeyword","description","getDescription","count","getLocale","getScore","createElement","as","href","target","rel","translate","isApplicable","hasKeyword","hasDescription"],"sources":["../../../../src/scoring/assessments/seo/MetaDescriptionKeywordAssessment.js"],"sourcesContent":["import React from 'react';\nimport {Text} from '@shopify/polaris';\n\nimport {isNumber, merge} from 'lodash';\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport {KeyIcon} from '@shopify/polaris-icons';\nimport matchTextWithWord from '@axyseo/languageProcessing/helpers/match/matchTextWithWord';\n\n/**\n * Assessment for checking the keyword matches in the meta description.\n */\nclass MetaDescriptionKeywordAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {Object} [config] The configuration to use.\n * @param {number} [config.parameters.recommendedMinimum] The recommended minimum of keyword occurrences in the meta description.\n * @param {number} [config.scores.good] The score to return if there are enough keyword occurrences in the meta description.\n * @param {number} [config.scores.bad] The score to return if there aren't enough keyword occurrences in the meta description.\n * @param {string} [config.url] The URL to the relevant article on Yoast.com.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'metaDescriptionKeyword',\n priority: 'high',\n fixPosition: 'meta description',\n ctaType: 'fix',\n docUrl: 'https://help.seoon.io/seo/seo-checklist',\n icon: KeyIcon,\n title: 'Meta description keyword',\n content: {\n bad: 'No keywords found in meta description. Add at least one to improve keyword rank.',\n good: 'Keywords are included meta description.',\n improve: ''\n }\n };\n\n this.identifier = 'metaDescriptionKeyword';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Runs the metaDescriptionKeyword researcher and based on this, returns an assessment result with score.\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 assessmentResult = new AssessmentResult({config: this._config});\n const calculatedResult = this.calculateResult(paper, 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 * Returns the result object based on the number of keyword matches in the meta description.\n *\n * @returns {Object} Result object with score and text.\n */\n calculateResult(paper, i18n) {\n const keyword = paper.getKeyword();\n const description = paper.getDescription();\n const {count} = matchTextWithWord(description, keyword, paper.getLocale(), null);\n\n let status = '';\n if (isNumber(count) && count > 0) {\n status = 'good';\n } else {\n status = 'bad';\n }\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n * Checks whether the paper has a keyword and a meta description.\n *\n * @param {Paper} paper The paper to use for the assessment.\n *\n * @returns {boolean} True if the paper has a keyword and a meta description.\n */\n isApplicable(paper) {\n return paper.hasKeyword() && paper.hasDescription();\n }\n}\n\nexport default MetaDescriptionKeywordAssessment;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,QAAO,kBAAkB;AAErC,SAAQC,QAAQ,EAAEC,KAAK,QAAO,QAAQ;AACtC,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AACvB,SAAQC,OAAO,QAAO,wBAAwB;AAC9C,OAAOC,iBAAiB;;AAExB;AACA;AACA;AACA,MAAMC,gCAAgC,SAASJ,UAAU,CAAC;EACxD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEK,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,wBAAwB;MAC5BC,QAAQ,EAAE,MAAM;MAChBC,WAAW,EAAE,kBAAkB;MAC/BC,OAAO,EAAE,KAAK;MACdC,MAAM,EAAE,yCAAyC;MACjDC,IAAI,EAAEX,OAAO;MACbY,KAAK,EAAE,0BAA0B;MACjCC,OAAO,EAAE;QACPC,GAAG,EAAE,kFAAkF;QACvFC,IAAI,EAAE,yCAAyC;QAC/CC,OAAO,EAAE;MACX;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAG,wBAAwB;IAC1C,IAAI,CAACC,OAAO,GAAGrB,KAAK,CAACQ,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEe,SAASA,CAAC;IAACC,KAAK;IAAEC,UAAU;IAAEC;EAAI,CAAC,EAAE;IACnC,MAAMC,gBAAgB,GAAG,IAAIxB,gBAAgB,CAAC;MAACK,MAAM,EAAE,IAAI,CAACc;IAAO,CAAC,CAAC;IACrE,MAAMM,gB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rB,IAAI,GAAGA,IAAI,CAACsB,SAAS,CAAC,yBAAyB,CAAC,GAAG,YACnD,CAED;IAEV,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,YAAYA,CAACzB,KAAK,EAAE;IAClB,OAAOA,KAAK,CAAC0B,UAAU,CAAC,CAAC,IAAI1B,KAAK,CAAC2B,cAAc,CAAC,CAAC;EACrD;AACF;AAEA,eAAe7C,gCAAgC","ignoreList":[]}
1
+ {"version":3,"file":"MetaDescriptionKeywordAssessment.js","names":["React","Text","isNumber","merge","Assessment","AssessmentResult","KeyIcon","matchTextWithWord","MetaDescriptionKeywordAssessment","constructor","config","defaultConfig","id","priority","fixPosition","ctaType","docUrl","icon","title","content","bad","good","improve","identifier","_config","getResult","paper","researcher","i18n","_keyphraseCounts","getResearch","assessmentResult","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","getScore","createElement","as","href","target","rel","translate","isApplicable","hasKeyword","hasDescription"],"sources":["../../../../src/scoring/assessments/seo/MetaDescriptionKeywordAssessment.js"],"sourcesContent":["import React from 'react';\nimport {Text} from '@shopify/polaris';\n\nimport {isNumber, merge} from 'lodash';\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport {KeyIcon} from '@shopify/polaris-icons';\nimport matchTextWithWord from '@axyseo/languageProcessing/helpers/match/matchTextWithWord';\n\n/**\n * Assessment for checking the keyword matches in the meta description.\n */\nclass MetaDescriptionKeywordAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {Object} [config] The configuration to use.\n * @param {number} [config.parameters.recommendedMinimum] The recommended minimum of keyword occurrences in the meta description.\n * @param {number} [config.scores.good] The score to return if there are enough keyword occurrences in the meta description.\n * @param {number} [config.scores.bad] The score to return if there aren't enough keyword occurrences in the meta description.\n * @param {string} [config.url] The URL to the relevant article on Yoast.com.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'metaDescriptionKeyword',\n priority: 'high',\n fixPosition: 'meta description',\n ctaType: 'fix',\n docUrl: 'https://help.seoon.io/seo/seo-checklist',\n icon: KeyIcon,\n title: 'Meta description keyword',\n content: {\n bad: 'No keywords found in meta description. Add at least one to improve keyword rank.',\n good: 'Keywords are included meta description.',\n improve: ''\n }\n };\n\n this.identifier = 'metaDescriptionKeyword';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Runs the metaDescriptionKeyword researcher and based on this, returns an assessment result with score.\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 this._keyphraseCounts = researcher.getResearch('metaDescriptionKeyword');\n\n const assessmentResult = new AssessmentResult({config: this._config});\n const calculatedResult = this.calculateResult(paper, 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 * Returns the result object based on the number of keyword matches in the meta description.\n *\n * @returns {Object} Result object with score and text.\n */\n calculateResult(paper, i18n) {\n let status = '';\n if (this._keyphraseCounts > 0) {\n status = 'good';\n } else {\n status = 'bad';\n }\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n * Checks whether the paper has a keyword and a meta description.\n *\n * @param {Paper} paper The paper to use for the assessment.\n *\n * @returns {boolean} True if the paper has a keyword and a meta description.\n */\n isApplicable(paper) {\n return paper.hasKeyword() && paper.hasDescription();\n }\n}\n\nexport default MetaDescriptionKeywordAssessment;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,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AAS,CAACJ,gBAAgB,CAACK,MAAM,CAAC;IACnDN,gBAAgB,CAACO,OAAO,CAACN,gBAAgB,CAACO,IAAI,CAAC;IAE/C,OAAOR,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;EACEE,eAAeA,CAACP,KAAK,EAAEE,IAAI,EAAE;IAC3B,IAAIS,MAAM,GAAG,EAAE;IACf,IAAI,IAAI,CAACR,gBAAgB,GAAG,CAAC,EAAE;MAC7BQ,MAAM,GAAG,MAAM;IACjB,CAAC,MAAM;MACLA,MAAM,GAAG,KAAK;IAChB;IACA,MAAMF,KAAK,GAAG,IAAI,CAACK,QAAQ,CAAC,IAAI,CAAChB,OAAO,CAACX,QAAQ,EAAEwB,MAAM,CAAC;IAE1D,OAAO;MACLF,KAAK;MACLE,MAAM;MACNE,IAAI,eACFvC,KAAA,CAAAyC,aAAA,CAACxC,IAAI;QAACyC,EAAE,EAAE;MAAO,GACd,IAAI,CAAClB,OAAO,CAACL,OAAO,CAACkB,MAAM,CAAC,EAAE,GAAG,EACjC,IAAI,CAACb,OAAO,CAACR,MAAM,iBAClBhB,KAAA,CAAAyC,aAAA;QAAGE,IAAI,EAAE,IAAI,CAACnB,OAAO,CAACR,MAAO;QAAC4B,MAAM,EAAC,QAAQ;QAACC,GAAG,EAAC;MAAY,GAC3DjB,IAAI,GAAGA,IAAI,CAACkB,SAAS,CAAC,yBAAyB,CAAC,GAAG,YACnD,CAED;IAEV,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,YAAYA,CAACrB,KAAK,EAAE;IAClB,OAAOA,KAAK,CAACsB,UAAU,CAAC,CAAC,IAAItB,KAAK,CAACuB,cAAc,CAAC,CAAC;EACrD;AACF;AAEA,eAAezC,gCAAgC","ignoreList":[]}
@@ -1,9 +1,8 @@
1
1
  import React from 'react';
2
2
  import { Text } from '@shopify/polaris';
3
- import { isNumber, merge } from 'lodash';
3
+ import { merge } from 'lodash';
4
4
  import Assessment from "../assessment";
5
5
  import AssessmentResult from "../../../values/AssessmentResult";
6
- import matchTextWithWord from "../../../languageProcessing/helpers/match/matchTextWithWord";
7
6
 
8
7
  /**
9
8
  * Assessment for checking the keyword matches in the meta title.
@@ -53,10 +52,13 @@ export default class MetaTitleKeywordAssessment extends Assessment {
53
52
  researcher,
54
53
  i18n
55
54
  }) {
55
+ this._keyphraseMatches = researcher.getResearch('findKeyphraseInSEOTitle');
56
56
  const assessmentResult = new AssessmentResult({
57
57
  config: this._config
58
58
  });
59
- const calculatedResult = this.calculateResult(paper, i18n);
59
+ const calculatedResult = this.calculateResult({
60
+ i18n
61
+ });
60
62
  assessmentResult.setScore(calculatedResult.score);
61
63
  assessmentResult.setStatus(calculatedResult.status);
62
64
  assessmentResult.setBody(calculatedResult.body);
@@ -68,16 +70,17 @@ export default class MetaTitleKeywordAssessment extends Assessment {
68
70
  *
69
71
  * @returns {Object} Result object with score and text.
70
72
  */
71
- calculateResult(paper, i18n) {
72
- const keyword = paper.getKeyword();
73
- const title = paper.getTitle();
74
- const {
75
- count
76
- } = matchTextWithWord(title, keyword, paper.getLocale(), null);
77
- let status = '';
78
- if (isNumber(count) && count > 0) {
73
+ calculateResult({
74
+ i18n
75
+ }) {
76
+ const exactMatchFound = this._keyphraseMatches.exactMatchFound;
77
+ const allWordsFound = this._keyphraseMatches.allWordsFound;
78
+ const exactMatchKeyphrase = this._keyphraseMatches.exactMatchKeyphrase;
79
+ let status = 'bad';
80
+ if (exactMatchFound === true || allWordsFound) {
79
81
  status = 'good';
80
- } else {
82
+ }
83
+ if (exactMatchKeyphrase) {
81
84
  status = 'bad';
82
85
  }
83
86
  const score = this.getScore(this._config.priority, status);
@@ -1 +1 @@
1
- {"version":3,"file":"MetaTitleKeywordAssessment.js","names":["React","Text","isNumber","merge","Assessment","AssessmentResult","matchTextWithWord","MetaTitleKeywordAssessment","constructor","config","defaultConfig","id","docUrl","fixPosition","ctaType","priority","title","content","bad","good","improve","identifier","_config","getResult","paper","researcher","i18n","assessmentResult","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","keyword","getKeyword","getTitle","count","getLocale","getScore","createElement","as","href","target","rel","translate","isApplicable","hasKeyword"],"sources":["../../../../src/scoring/assessments/seo/MetaTitleKeywordAssessment.js"],"sourcesContent":["import React from 'react';\nimport {Text} from '@shopify/polaris';\n\nimport {isNumber, merge} from 'lodash';\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport matchTextWithWord from '@axyseo/languageProcessing/helpers/match/matchTextWithWord';\n\n/**\n * Assessment for checking the keyword matches in the meta title.\n */\nexport default class MetaTitleKeywordAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {Object} [config] The configuration to use.\n * @param {number} [config.parameters.recommendedMinimum] The recommended minimum of keyword occurrences in the meta description.\n * @param {number} [config.scores.good] The score to return if there are enough keyword occurrences in the meta description.\n * @param {number} [config.scores.bad] The score to return if there aren't enough keyword occurrences in the meta description.\n * @param {string} [config.url] The URL to the relevant article on Yoast.com.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'titleKeyword',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#keyword-in-title',\n fixPosition: 'meta title',\n ctaType: 'fix',\n priority: 'high',\n title: 'Keyword in meta title',\n content: {\n bad:\n 'No keywords found in meta title. Add one to improve keyword rank and click through rate.',\n good: 'Keyword is included in meta title.',\n improve: ''\n }\n };\n\n this.identifier = 'titleKeyword';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Runs the metaDescriptionKeyword researcher and based on this, returns an assessment result with score.\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 assessmentResult = new AssessmentResult({config: this._config});\n const calculatedResult = this.calculateResult(paper, 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 * Returns the result object based on the number of keyword matches in the meta description.\n *\n * @returns {Object} Result object with score and text.\n */\n calculateResult(paper, i18n) {\n const keyword = paper.getKeyword();\n const title = paper.getTitle();\n const {count} = matchTextWithWord(title, keyword, paper.getLocale(), null);\n\n let status = '';\n if (isNumber(count) && count > 0) {\n status = 'good';\n } else {\n status = 'bad';\n }\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n * Checks whether the paper has a keyword and a meta description.\n *\n * @param {Paper} paper The paper to use for the assessment.\n *\n * @returns {boolean} True if the paper has a keyword and a meta description.\n */\n isApplicable(paper) {\n return paper.hasKeyword();\n }\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,QAAO,kBAAkB;AAErC,SAAQC,QAAQ,EAAEC,KAAK,QAAO,QAAQ;AACtC,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AACvB,OAAOC,iBAAiB;;AAExB;AACA;AACA;AACA,eAAe,MAAMC,0BAA0B,SAASH,UAAU,CAAC;EACjE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEI,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,cAAc;MAClBC,MAAM,EACJ,8FAA8F;MAChGC,WAAW,EAAE,YAAY;MACzBC,OAAO,EAAE,KAAK;MACdC,QAAQ,EAAE,MAAM;MAChBC,KAAK,EAAE,uBAAuB;MAC9BC,OAAO,EAAE;QACPC,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,QAAQ,CAAC,IAAI,CAACnB,OAAO,CAACP,QAAQ,EAAEkB,MAAM,CAAC;IAE1D,OAAO;MACLF,KAAK;MACLE,MAAM;MACNE,IAAI,eACFnC,KAAA,CAAA0C,aAAA,CAACzC,IAAI;QAAC0C,EAAE,EAAE;MAAO,GACd,IAAI,CAACrB,OAAO,CAACL,OAAO,CAACgB,MAAM,CAAC,EAAE,GAAG,EACjC,IAAI,CAACX,OAAO,CAACV,MAAM,iBAClBZ,KAAA,CAAA0C,aAAA;QAAGE,IAAI,EAAE,IAAI,CAACtB,OAAO,CAACV,MAAO;QAACiC,MAAM,EAAC,QAAQ;QAACC,GAAG,EAAC;MAAY,GAC3DpB,IAAI,GAAGA,IAAI,CAACqB,SAAS,CAAC,yBAAyB,CAAC,GAAG,YACnD,CAED;IAEV,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,YAAYA,CAACxB,KAAK,EAAE;IAClB,OAAOA,KAAK,CAACyB,UAAU,CAAC,CAAC;EAC3B;AACF","ignoreList":[]}
1
+ {"version":3,"file":"MetaTitleKeywordAssessment.js","names":["React","Text","merge","Assessment","AssessmentResult","MetaTitleKeywordAssessment","constructor","config","defaultConfig","id","docUrl","fixPosition","ctaType","priority","title","content","bad","good","improve","identifier","_config","getResult","paper","researcher","i18n","_keyphraseMatches","getResearch","assessmentResult","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","exactMatchFound","allWordsFound","exactMatchKeyphrase","getScore","createElement","as","href","target","rel","translate","isApplicable","hasKeyword"],"sources":["../../../../src/scoring/assessments/seo/MetaTitleKeywordAssessment.js"],"sourcesContent":["import React from 'react';\nimport {Text} from '@shopify/polaris';\n\nimport {merge} from 'lodash';\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\n\n/**\n * Assessment for checking the keyword matches in the meta title.\n */\nexport default class MetaTitleKeywordAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {Object} [config] The configuration to use.\n * @param {number} [config.parameters.recommendedMinimum] The recommended minimum of keyword occurrences in the meta description.\n * @param {number} [config.scores.good] The score to return if there are enough keyword occurrences in the meta description.\n * @param {number} [config.scores.bad] The score to return if there aren't enough keyword occurrences in the meta description.\n * @param {string} [config.url] The URL to the relevant article on Yoast.com.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'titleKeyword',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#keyword-in-title',\n fixPosition: 'meta title',\n ctaType: 'fix',\n priority: 'high',\n title: 'Keyword in meta title',\n content: {\n bad:\n 'No keywords found in meta title. Add one to improve keyword rank and click through rate.',\n good: 'Keyword is included in meta title.',\n improve: ''\n }\n };\n\n this.identifier = 'titleKeyword';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Runs the metaDescriptionKeyword researcher and based on this, returns an assessment result with score.\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 this._keyphraseMatches = researcher.getResearch('findKeyphraseInSEOTitle');\n\n const assessmentResult = new AssessmentResult({\n config: this._config\n });\n const calculatedResult = this.calculateResult({\n i18n\n });\n\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Returns the result object based on the number of keyword matches in the meta description.\n *\n * @returns {Object} Result object with score and text.\n */\n calculateResult({i18n}) {\n const exactMatchFound = this._keyphraseMatches.exactMatchFound;\n const allWordsFound = this._keyphraseMatches.allWordsFound;\n const exactMatchKeyphrase = this._keyphraseMatches.exactMatchKeyphrase;\n\n let status = 'bad';\n if (exactMatchFound === true || allWordsFound) {\n status = 'good';\n }\n if (exactMatchKeyphrase) {\n status = 'bad';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n * Checks whether the paper has a keyword and a meta description.\n *\n * @param {Paper} paper The paper to use for the assessment.\n *\n * @returns {boolean} True if the paper has a keyword and a meta description.\n */\n isApplicable(paper) {\n return paper.hasKeyword();\n }\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,QAAO,kBAAkB;AAErC,SAAQC,KAAK,QAAO,QAAQ;AAC5B,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;;AAEvB;AACA;AACA;AACA,eAAe,MAAMC,0BAA0B,SAASF,UAAU,CAAC;EACjE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEG,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,cAAc;MAClBC,MAAM,EACJ,8FAA8F;MAChGC,WAAW,EAAE,YAAY;MACzBC,OAAO,EAAE,KAAK;MACdC,QAAQ,EAAE,MAAM;MAChBC,KAAK,EAAE,uBAAuB;MAC9BC,OAAO,EAAE;QACPC,GAAG,EACD,0FAA0F;QAC5FC,IAAI,EAAE,oCAAoC;QAC1CC,OAAO,EAAE;MACX;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAG,cAAc;IAChC,IAAI,CAACC,OAAO,GAAGlB,KAAK,CAACM,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEc,SAASA,CAAC;IAACC,KAAK;IAAEC,UAAU;IAAEC;EAAI,CAAC,EAAE;IACnC,IAAI,CAACC,iBAAiB,GAAGF,UAAU,CAACG,W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,CAACV,MAAO;QAACiC,MAAM,EAAC,QAAQ;QAACC,GAAG,EAAC;MAAY,GAC3DpB,IAAI,GAAGA,IAAI,CAACqB,SAAS,CAAC,yBAAyB,CAAC,GAAG,YACnD,CAED;IAEV,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,YAAYA,CAACxB,KAAK,EAAE;IAClB,OAAOA,KAAK,CAACyB,UAAU,CAAC,CAAC;EAC3B;AACF","ignoreList":[]}
@@ -88,7 +88,7 @@ export default class SchemaAssessment extends Assessment {
88
88
  const assessmentResult = new AssessmentResult({
89
89
  config: this._config
90
90
  });
91
- assessmentResult.setStatus(calculatedResult.status);
91
+ assessmentResult.setScore(calculatedResult.score);
92
92
  assessmentResult.setStatus(calculatedResult.status);
93
93
  assessmentResult.setBody(calculatedResult.body);
94
94
  return assessmentResult;
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaAssessment.js","names":["merge","React","Text","AssessmentResult","Assessment","SchemaAssessment","constructor","config","defaultConfig","id","priority","docUrl","ctaType","title","content","good","improve","bad","identifier","_config","calculateResult","paper","i18n","status","url","getSlug","shopSettings","getShopSettings","includes","hasProductSchema","blogPostsAndArticle","score","getScore","body","createElement","as","href","target","rel","translate","getResult","researcher","calculatedResult","assessmentResult","setStatus","setBody","isApplicable","hasShopSettings","hasSlug"],"sources":["../../../../src/scoring/assessments/seo/SchemaAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\n\n/**\n * Represents the assessment that checks shop has schema.\n */\nexport default class SchemaAssessment 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: 'schema',\n priority: 'high',\n docUrl: 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#schema',\n ctaType: 'contactUs',\n title: 'Schema',\n content: {\n good: 'Schema markup is applied effectively.',\n improve: '',\n bad: 'No schema markup applied. Add schema to optimize visibility for search engines.'\n }\n };\n\n this.identifier = 'schema';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n *\n * @param paper\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(paper, i18n) {\n let status = '';\n const url = paper.getSlug();\n const shopSettings = paper.getShopSettings();\n if (url.includes('product') || url.includes('collection')) {\n if (paper.hasProductSchema()) {\n status = 'good';\n } else {\n status = 'bad';\n }\n }\n if (url.includes('blogs')) {\n if (shopSettings?.blogPostsAndArticle?.status) {\n status = 'good';\n } else {\n status = 'bad';\n }\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @param config\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const calculatedResult = this.calculateResult(paper, i18n);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setStatus(calculatedResult.status);\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 * @returns {boolean} Returns true if the language is available and the paper is not empty.\n */\n isApplicable(paper, researcher) {\n return paper.hasShopSettings() && paper.hasSlug();\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,QAAO,kBAAkB;AACrC,OAAOC,gBAAgB;AACvB,OAAO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":3,"file":"SchemaAssessment.js","names":["merge","React","Text","AssessmentResult","Assessment","SchemaAssessment","constructor","config","defaultConfig","id","priority","docUrl","ctaType","title","content","good","improve","bad","identifier","_config","calculateResult","paper","i18n","status","url","getSlug","shopSettings","getShopSettings","includes","hasProductSchema","blogPostsAndArticle","score","getScore","body","createElement","as","href","target","rel","translate","getResult","researcher","calculatedResult","assessmentResult","setScore","setStatus","setBody","isApplicable","hasShopSettings","hasSlug"],"sources":["../../../../src/scoring/assessments/seo/SchemaAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\n\n/**\n * Represents the assessment that checks shop has schema.\n */\nexport default class SchemaAssessment 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: 'schema',\n priority: 'high',\n docUrl: 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#schema',\n ctaType: 'contactUs',\n title: 'Schema',\n content: {\n good: 'Schema markup is applied effectively.',\n improve: '',\n bad: 'No schema markup applied. Add schema to optimize visibility for search engines.'\n }\n };\n\n this.identifier = 'schema';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n *\n * @param paper\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(paper, i18n) {\n let status = '';\n const url = paper.getSlug();\n const shopSettings = paper.getShopSettings();\n if (url.includes('product') || url.includes('collection')) {\n if (paper.hasProductSchema()) {\n status = 'good';\n } else {\n status = 'bad';\n }\n }\n if (url.includes('blogs')) {\n if (shopSettings?.blogPostsAndArticle?.status) {\n status = 'good';\n } else {\n status = 'bad';\n }\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @param config\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const calculatedResult = this.calculateResult(paper, i18n);\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 * @returns {boolean} Returns true if the language is available and the paper is not empty.\n */\n isApplicable(paper, researcher) {\n return paper.hasShopSettings() && paper.hasSlug();\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,QAAO,kBAAkB;AACrC,OAAOC,gBAAgB;AACvB,OAAOC,UAAU;;AAEjB;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAASD,UAAU,CAAC;EACvD;AACF;AACA;AACA;AACA;AACA;AACA;EACEE,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,QAAQ;MACZC,QAAQ,EAAE,MAAM;MAChBC,MAAM,EAAE,oFAAoF;MAC5FC,OAAO,EAAE,WAAW;MACpBC,KAAK,EAAE,QAAQ;MACfC,OAAO,EAAE;QACPC,IAAI,EAAE,uCAAuC;QAC7CC,OAAO,EAAE,EAAE;QACXC,GAAG,EAAE;MACP;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAG,QAAQ;IAC1B,IAAI,CAACC,OAAO,GAAGnB,KAAK,CAACQ,aAAa,EAAED,MAAM,CAAC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ACA;AACA;AACA;EACEC,SAASA,CAAC;IAACnB,KAAK;IAAEoB,UAAU;IAAEnB;EAAI,CAAC,EAAE;IACnC,MAAMoB,gBAAgB,GAAG,IAAI,CAACtB,eAAe,CAACC,KAAK,EAAEC,IAAI,CAAC;IAC1D,MAAMqB,gBAAgB,GAAG,IAAIxC,gBAAgB,CAAC;MAACI,MAAM,EAAE,IAAI,CAACY;IAAO,CAAC,CAAC;IAErEwB,gBAAgB,CAACC,QAAQ,CAACF,gBAAgB,CAACX,KAAK,CAAC;IACjDY,gBAAgB,CAACE,SAAS,CAACH,gBAAgB,CAACnB,MAAM,CAAC;IACnDoB,gBAAgB,CAACG,OAAO,CAACJ,gBAAgB,CAACT,IAAI,CAAC;IAE/C,OAAOU,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEI,YAAYA,CAAC1B,KAAK,EAAEoB,UAAU,EAAE;IAC9B,OAAOpB,KAAK,CAAC2B,eAAe,CAAC,CAAC,IAAI3B,KAAK,CAAC4B,OAAO,CAAC,CAAC;EACnD;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "axyseo",
3
- "version": "2.0.0-alpha.0.0.40",
3
+ "version": "2.0.0-alpha.0.0.42",
4
4
  "main": "build/index.js",
5
5
  "scripts": {
6
6
  "prepublishOnly": "npm run build && npm version prerelease --preid=alpha",
7
7
  "build": "yarn clean && yarn build:js && yarn build:types",
8
+ "watch": "nodemon",
8
9
  "build:js": "babel src --copy-files --source-maps --out-dir build",
9
10
  "build:types": "tsc",
10
11
  "clean": "rm -rf build",
@@ -34,10 +35,9 @@
34
35
  "blob-polyfill": "^7.0.20220408",
35
36
  "console.table": "^0.10.0",
36
37
  "eslint": "^9.16.0",
37
- "prettier": "^1.18.2",
38
- "eslint-config-yoast": "^6.0.0",
39
38
  "eslint-config-google": "^0.14.0",
40
39
  "eslint-config-prettier": "^6.2.0",
40
+ "eslint-config-yoast": "^6.0.0",
41
41
  "eslint-plugin-prettier": "^3.1.0",
42
42
  "eslint-plugin-react": "^7.16.0",
43
43
  "globals": "^15.12.0",
@@ -45,6 +45,8 @@
45
45
  "grunt-shell": "^4.0.0",
46
46
  "js-yaml": "^4.1.0",
47
47
  "load-grunt-config": "^1.0.0",
48
+ "nodemon": "^3.1.9",
49
+ "prettier": "^1.18.2",
48
50
  "typescript": "^5.6.3"
49
51
  }
50
52
  }