axyseo 2.1.54 → 2.1.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/languageProcessing/researches/findKeywordInFirstParagraph.js +21 -0
- package/build/cjs/languageProcessing/researches/findKeywordInFirstParagraph.js.map +1 -1
- package/build/cjs/scoring/assessments/seo/RelatedKeywordsDensityAssessment.js +0 -1
- package/build/cjs/scoring/assessments/seo/RelatedKeywordsDensityAssessment.js.map +1 -1
- package/build/cjs/values/Paper.js +1 -1
- package/build/cjs/values/Paper.js.map +1 -1
- package/build/esm/languageProcessing/researches/findKeywordInFirstParagraph.js +21 -0
- package/build/esm/languageProcessing/researches/findKeywordInFirstParagraph.js.map +1 -1
- package/build/esm/scoring/assessments/seo/RelatedKeywordsDensityAssessment.js +0 -1
- package/build/esm/scoring/assessments/seo/RelatedKeywordsDensityAssessment.js.map +1 -1
- package/build/esm/values/Paper.js +1 -1
- package/build/esm/values/Paper.js.map +1 -1
- package/package.json +1 -1
|
@@ -12,6 +12,12 @@ var _isChineseText = _interopRequireDefault(require("../helpers/language/isChine
|
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
/** @module analyses/findKeywordInFirstParagraph */
|
|
14
14
|
|
|
15
|
+
// Matches common UI-marker class names (label, eyebrow, kicker, etc.) used for
|
|
16
|
+
// short text placed above a heading. Anchored to the start, with a boundary so
|
|
17
|
+
// `header-label` or `tagline` don't match.
|
|
18
|
+
const LABEL_LIKE_CLASS_REGEX = /^(label|eyebrow|kicker|overline|pretitle|subtitle|badge|tag|chip|meta|category|breadcrumb)(\b|[-_])/i;
|
|
19
|
+
const MIN_INTRO_WORDS = 5;
|
|
20
|
+
|
|
15
21
|
/**
|
|
16
22
|
* Checks if the introductory paragraph contains keyphrase or synonyms.
|
|
17
23
|
* First splits the first paragraph by sentences. Finds the first paragraph which contains sentences e.g., not an image).
|
|
@@ -42,6 +48,21 @@ function _default(paper, researcher) {
|
|
|
42
48
|
paragraphs = paragraphs.filter(paragraph => {
|
|
43
49
|
return !(paragraph.childNodes && paragraph.childNodes[0] && (0, _helpers.createShortcodeTagsRegex)(['caption']).test(paragraph.childNodes[0].value));
|
|
44
50
|
});
|
|
51
|
+
// Filter UI label/eyebrow/kicker paragraphs that sit before the heading
|
|
52
|
+
// (e.g., <p class="label">CATEGORY</p>). These are visual markers, not real
|
|
53
|
+
// intro paragraphs, and would cause false negatives on keyword-in-intro checks.
|
|
54
|
+
paragraphs = paragraphs.filter(paragraph => {
|
|
55
|
+
const classSet = paragraph.attributes && paragraph.attributes.class;
|
|
56
|
+
if (classSet instanceof Set) {
|
|
57
|
+
for (const cls of classSet) {
|
|
58
|
+
if (LABEL_LIKE_CLASS_REGEX.test(cls)) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const wordCount = (paragraph.innerText() || '').trim().split(/\s+/).filter(Boolean).length;
|
|
64
|
+
return wordCount >= MIN_INTRO_WORDS;
|
|
65
|
+
});
|
|
45
66
|
const firstParagraph = paragraphs[0];
|
|
46
67
|
const topicForms = researcher.getResearch('morphology');
|
|
47
68
|
let matchWordCustomHelper = researcher.getHelper('matchWordCustomHelper');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findKeywordInFirstParagraph.js","names":["_lodash","require","_findKeywordFormsInString","_getSentencesFromTree","_helpers","_isChineseText","_interopRequireDefault","e","__esModule","default","_default","paper","researcher","paragraphs","getResearch","filter","paragraph","parentNode","getParentNode","isImplicit","name","childNodes","createShortcodeTagsRegex","test","value","firstParagraph","topicForms","matchWordCustomHelper","getHelper","locale","getLocale","isChineseText","getKeyword","innerText","text","word","textToSearch","matches","lowerText","toLowerCase","lowerWord","startIndex","index","indexOf","push","length","startOffset","sourceCodeLocation","mappedBlocks","_attributes","wpBlocks","filteredIntroductionBlock","block","inRange","endOffset","result","foundInOneSentence","foundInParagraph","keyphraseOrSynonym","introduction","parentBlock","isEmpty","sentences","map","sentence","useSynonyms","firstResultSentence","findTopicFormsInString","find","resultSentence","percentWordMatches","resultParagraph"],"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';\nimport isChineseText from '../helpers/language/isChineseText';\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 let matchWordCustomHelper = researcher.getHelper('matchWordCustomHelper');\n const locale = paper.getLocale();\n\n // Auto-detect Chinese and use Chinese helper if not already available\n if (\n !matchWordCustomHelper &&\n isChineseText(paper.getKeyword() + ' ' + (firstParagraph ? firstParagraph.innerText() : ''))\n ) {\n // Use Chinese word matching for Chinese text\n matchWordCustomHelper = function(text, word) {\n const textToSearch = typeof text === 'string' ? text : text.text || text;\n const matches = [];\n\n if (!textToSearch || !word) {\n return matches;\n }\n\n const lowerText = textToSearch.toLowerCase();\n const lowerWord = word.toLowerCase();\n\n let startIndex = 0;\n let index;\n\n while ((index = lowerText.indexOf(lowerWord, startIndex)) !== -1) {\n matches.push(word);\n startIndex = index + lowerWord.length;\n }\n\n return matches;\n };\n }\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":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,yBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAC,sBAAA,CAAAL,OAAA;AAA8D,SAAAK,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAN9D;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAAAG,SAASC,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,GAAG,IAAAC,mCAAa,EAACP,KAAK,EAAEK,SAAS,CAAC;IAClD,OAAO,EAAEA,SAAS,CAACG,UAAU,IAAIF,UAAU,IAAIA,UAAU,CAACG,IAAI,KAAK,YAAY,CAAC;EAClF,CAAC,CAAC;EACF;EACAP,UAAU,GAAGA,UAAU,CAACE,MAAM,CAACC,SAAS,IAAI;IAC1C,OAAO,EACLA,SAAS,CAACK,UAAU,IACpBL,SAAS,CAACK,UAAU,CAAC,CAAC,CAAC,IACvB,IAAAC,iCAAwB,EAAC,CAAC,SAAS,CAAC,CAAC,CAACC,IAAI,CAACP,SAAS,CAACK,UAAU,CAAC,CAAC,CAAC,CAACG,KAAK,CAAC,CAC1E;EACH,CAAC,CAAC;EACF,MAAMC,cAAc,G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AAe,CAACD,kBAAkB,KAAK,GAAG,EAAE;MAC9Cf,MAAM,CAACE,gBAAgB,GAAG,IAAI;MAC9BF,MAAM,CAACG,kBAAkB,GAAGa,eAAe,CAACb,kBAAkB;MAC9D,OAAOH,MAAM;IACf;EACF;EAEA,OAAOA,MAAM;AACf","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"findKeywordInFirstParagraph.js","names":["_lodash","require","_findKeywordFormsInString","_getSentencesFromTree","_helpers","_isChineseText","_interopRequireDefault","e","__esModule","default","LABEL_LIKE_CLASS_REGEX","MIN_INTRO_WORDS","_default","paper","researcher","paragraphs","getResearch","filter","paragraph","parentNode","getParentNode","isImplicit","name","childNodes","createShortcodeTagsRegex","test","value","classSet","attributes","class","Set","cls","wordCount","innerText","trim","split","Boolean","length","firstParagraph","topicForms","matchWordCustomHelper","getHelper","locale","getLocale","isChineseText","getKeyword","text","word","textToSearch","matches","lowerText","toLowerCase","lowerWord","startIndex","index","indexOf","push","startOffset","sourceCodeLocation","mappedBlocks","_attributes","wpBlocks","filteredIntroductionBlock","block","inRange","endOffset","result","foundInOneSentence","foundInParagraph","keyphraseOrSynonym","introduction","parentBlock","isEmpty","sentences","map","sentence","useSynonyms","firstResultSentence","findTopicFormsInString","find","resultSentence","percentWordMatches","resultParagraph"],"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';\nimport isChineseText from '../helpers/language/isChineseText';\n\n// Matches common UI-marker class names (label, eyebrow, kicker, etc.) used for\n// short text placed above a heading. Anchored to the start, with a boundary so\n// `header-label` or `tagline` don't match.\nconst LABEL_LIKE_CLASS_REGEX = /^(label|eyebrow|kicker|overline|pretitle|subtitle|badge|tag|chip|meta|category|breadcrumb)(\\b|[-_])/i;\nconst MIN_INTRO_WORDS = 5;\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 // Filter UI label/eyebrow/kicker paragraphs that sit before the heading\n // (e.g., <p class=\"label\">CATEGORY</p>). These are visual markers, not real\n // intro paragraphs, and would cause false negatives on keyword-in-intro checks.\n paragraphs = paragraphs.filter(paragraph => {\n const classSet = paragraph.attributes && paragraph.attributes.class;\n if (classSet instanceof Set) {\n for (const cls of classSet) {\n if (LABEL_LIKE_CLASS_REGEX.test(cls)) {\n return false;\n }\n }\n }\n const wordCount = (paragraph.innerText() || '')\n .trim()\n .split(/\\s+/)\n .filter(Boolean).length;\n return wordCount >= MIN_INTRO_WORDS;\n });\n const firstParagraph = paragraphs[0];\n\n const topicForms = researcher.getResearch('morphology');\n let matchWordCustomHelper = researcher.getHelper('matchWordCustomHelper');\n const locale = paper.getLocale();\n\n // Auto-detect Chinese and use Chinese helper if not already available\n if (\n !matchWordCustomHelper &&\n isChineseText(paper.getKeyword() + ' ' + (firstParagraph ? firstParagraph.innerText() : ''))\n ) {\n // Use Chinese word matching for Chinese text\n matchWordCustomHelper = function(text, word) {\n const textToSearch = typeof text === 'string' ? text : text.text || text;\n const matches = [];\n\n if (!textToSearch || !word) {\n return matches;\n }\n\n const lowerText = textToSearch.toLowerCase();\n const lowerWord = word.toLowerCase();\n\n let startIndex = 0;\n let index;\n\n while ((index = lowerText.indexOf(lowerWord, startIndex)) !== -1) {\n matches.push(word);\n startIndex = index + lowerWord.length;\n }\n\n return matches;\n };\n }\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":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,yBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAC,sBAAA,CAAAL,OAAA;AAA8D,SAAAK,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAN9D;;AAQA;AACA;AACA;AACA,MAAMG,sBAAsB,GAAG,sGAAsG;AACrI,MAAMC,eAAe,GAAG,CAAC;;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAAAC,SAASC,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,GAAG,IAAAC,mCAAa,EAACP,KAAK,EAAEK,SAAS,CAAC;IAClD,OAAO,EAAEA,SAAS,CAACG,UAAU,IAAIF,UAAU,IAAIA,UAAU,CAACG,IAAI,KAAK,YAAY,CAAC;EAClF,CAAC,CAAC;EACF;EACAP,UAAU,GAAGA,UAAU,CAACE,MAAM,CAACC,SAAS,IAAI;IAC1C,OAAO,EACLA,SAAS,CAACK,UAAU,IACpBL,SAAS,CAACK,UAAU,CAAC,CAAC,CAAC,IACvB,IAAAC,iCAAwB,EAAC,CAAC,S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,CAAC7B,IAAI,CAAC;EACzE;EACA,MAAM8B,WAAW,GAAG,IAAI;EAExB,IAAI,CAAC,IAAAJ,eAAO,EAACC,SAAS,CAAC,EAAE;IACvB,MAAMI,mBAAmB,GAAGJ,SAAS,CAClCC,GAAG,CAACC,QAAQ,IACX,IAAAG,gDAAsB,EAACvC,UAAU,EAAEoC,QAAQ,EAAEC,WAAW,EAAElC,MAAM,EAAEF,qBAAqB,CACzF,CAAC,CACAuC,IAAI,CAACC,cAAc,IAAIA,cAAc,CAACC,kBAAkB,KAAK,GAAG,CAAC;IAEpE,IAAIJ,mBAAmB,EAAE;MACvBX,MAAM,CAACC,kBAAkB,GAAG,IAAI;MAChCD,MAAM,CAACE,gBAAgB,GAAG,IAAI;MAC9BF,MAAM,CAACG,kBAAkB,GAAGQ,mBAAmB,CAACR,kBAAkB;MAClE,OAAOH,MAAM;IACf;IAEA,MAAMgB,eAAe,GAAG,IAAAJ,gDAAsB,EAC5CvC,UAAU,EACVD,cAAc,CAACL,SAAS,CAAC,CAAC,EAC1B2C,WAAW,EACXlC,MAAM,EACNF,qBACF,CAAC;IACD,IAAI0C,eAAe,CAACD,kBAAkB,KAAK,GAAG,EAAE;MAC9Cf,MAAM,CAACE,gBAAgB,GAAG,IAAI;MAC9BF,MAAM,CAACG,kBAAkB,GAAGa,eAAe,CAACb,kBAAkB;MAC9D,OAAOH,MAAM;IACf;EACF;EAEA,OAAOA,MAAM;AACf","ignoreList":[]}
|
|
@@ -52,7 +52,6 @@ class RelatedKeywordsDensityAssessment extends _assessment.default {
|
|
|
52
52
|
} = relatedKeywords;
|
|
53
53
|
let status = 'good';
|
|
54
54
|
const totalWords = Object.values(words).filter(word => word.percentage === 0);
|
|
55
|
-
console.log("Related keyword density check: ", !hasDescription, (0, _lodash.isEmpty)(words), totalWords.length > 0);
|
|
56
55
|
if (!hasDescription || (0, _lodash.isEmpty)(words) || totalWords.length > 0) {
|
|
57
56
|
status = 'bad';
|
|
58
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelatedKeywordsDensityAssessment.js","names":["_lodash","require","_AssessmentResult","_interopRequireDefault","_assessment","_analysis","e","__esModule","default","RelatedKeywordsDensityAssessment","Assessment","constructor","config","defaultConfig","id","RELATED_KEYWORDS_DENSITY_ID","fixPosition","ctaType","docUrl","priority","title","content","good","bad","improve","identifier","_config","merge","calculateResult","data","relatedKeywords","hasDescription","words","status","totalWords","Object","values","filter","word","percentage","
|
|
1
|
+
{"version":3,"file":"RelatedKeywordsDensityAssessment.js","names":["_lodash","require","_AssessmentResult","_interopRequireDefault","_assessment","_analysis","e","__esModule","default","RelatedKeywordsDensityAssessment","Assessment","constructor","config","defaultConfig","id","RELATED_KEYWORDS_DENSITY_ID","fixPosition","ctaType","docUrl","priority","title","content","good","bad","improve","identifier","_config","merge","calculateResult","data","relatedKeywords","hasDescription","words","status","totalWords","Object","values","filter","word","percentage","isEmpty","length","score","getScore","MAIN_CONTENT_POINTS","getResult","paper","researcher","getResearch","getData","result","assessmentResult","AssessmentResult","setScore","setStatus","setData","isApplicable","exports"],"sources":["../../../../../src/scoring/assessments/seo/RelatedKeywordsDensityAssessment.js"],"sourcesContent":["import {isEmpty, merge} from 'lodash';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\nimport {MAIN_CONTENT_POINTS, RELATED_KEYWORDS_DENSITY_ID} from '@axyseo/const/analysis';\n\n/**\n * Represents the assessment that checks whether there are enough transition words in the text.\n */\nexport default class RelatedKeywordsDensityAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {object} config The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: RELATED_KEYWORDS_DENSITY_ID,\n fixPosition: 'description',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#related-keywords',\n priority: 'high',\n title: 'Related keywords density',\n content: {\n good: 'Related keywords density optimized',\n bad:\n 'Use each secondary keyword from 0.5% to 1%. Place where it reads naturally.',\n improve: ''\n }\n };\n\n this.identifier = RELATED_KEYWORDS_DENSITY_ID;\n this._config = merge(defaultConfig, config);\n }\n\n /**\n *\n * @param data\n * @param relatedKeywords\n * @param hasDescription\n * @returns {{score: number, status: string, words}}\n */\n calculateResult(data, relatedKeywords, hasDescription) {\n const {words} = relatedKeywords;\n let status = 'good';\n const totalWords = Object.values(words).filter(word => word.percentage === 0);\n if(!hasDescription || isEmpty(words) || totalWords.length > 0){\n status = 'bad';\n }\n const score = this.getScore(MAIN_CONTENT_POINTS, status);\n\n return {\n score,\n status,\n words\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher}) {\n const relatedKeywords = researcher.getResearch('checkRelatedKeywords');\n const data = paper.getData();\n const hasDescription = paper.hasDescription();\n const result = this.calculateResult(data, relatedKeywords, hasDescription);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(result.score);\n assessmentResult.setStatus(result.status);\n assessmentResult.setData(result.words);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the transition words assessment is applicable to the paper. Language-specific length requirements and methods of counting text length\n * may apply (e.g. for Japanese, the text should be counted in characters instead of words, which also makes the minimum required length higher).\n *\n * @param {Paper} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available, the paper is not empty and the text is longer than the minimum required length.\n */\n isApplicable(paper, researcher) {\n return true;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAAwF,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExF;A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E;IAC7B,MAAMjB,eAAe,GAAGiB,UAAU,CAACC,WAAW,CAAC,sBAAsB,CAAC;IACtE,MAAMnB,IAAI,GAAGiB,KAAK,CAACG,OAAO,CAAC,CAAC;IAC5B,MAAMlB,cAAc,GAAGe,KAAK,CAACf,cAAc,CAAC,CAAC;IAC7C,MAAMmB,MAAM,GAAG,IAAI,CAACtB,eAAe,CAACC,IAAI,EAAEC,eAAe,EAAEC,cAAc,CAAC;IAC1E,MAAMoB,gBAAgB,GAAG,IAAIC,yBAAgB,CAAC;MAACxC,MAAM,EAAE,IAAI,CAACc;IAAO,CAAC,CAAC;IAErEyB,gBAAgB,CAACE,QAAQ,CAACH,MAAM,CAACR,KAAK,CAAC;IACvCS,gBAAgB,CAACG,SAAS,CAACJ,MAAM,CAACjB,MAAM,CAAC;IACzCkB,gBAAgB,CAACI,OAAO,CAACL,MAAM,CAAClB,KAAK,CAAC;IAEtC,OAAOmB,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEK,YAAYA,CAACV,KAAK,EAAEC,UAAU,EAAE;IAC9B,OAAO,IAAI;EACb;AACF;AAACU,OAAA,CAAAjD,OAAA,GAAAC,gCAAA","ignoreList":[]}
|
|
@@ -213,7 +213,7 @@ class Paper {
|
|
|
213
213
|
* @returns {boolean} Returns true if the paper has a description.
|
|
214
214
|
*/
|
|
215
215
|
hasDescription() {
|
|
216
|
-
return this._attributes.
|
|
216
|
+
return this._attributes?.data?.body_html !== '' || this._attributes?.data?.descriptionHtml !== '';
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Paper.js","names":["_lodash","require","_helpers","_checkRelatedKeywords","defaultAttributes","keyword","synonyms","description","title","titleWidth","titleCount","h1Count","slug","domain","locale","permalink","date","customData","textTitle","writingDirection","wpBlocks","isFrontPage","pageType","Paper","constructor","text","attributes","_text","cleanHTML","_tree","defaults","hasOwnProperty","url","onlyLetters","replace","isEmpty","_attributes","hasKeyword","getKeyword","getAttributes","hasSynonyms","getSynonyms","getRelatedKeywords","data","getData","related_keywords","map","hasH1Count","isNull","getH1Count","hasTitleCount","getTitleCount","hasText","getText","getDomain","setTree","tree","getTree","hasDescription","getDescription","hasTitle","getTitle","hasTitleWidth","getTitleWidth","hasSlug","hasShopSettings","shopSettings","getSlug","hasProductSchema","hasFAQsSchema","hasFAQs","getFAQs","length","hasArticleSchema","hasData","isObject","hasRelatedKeywords","relatedKeywords","Array","isArray","getIgnoredAssessments","ignoredAssessments","getPageType","getSkippedAssessments","skippedAssessments","getShopSettings","hasUrl","console","warn","getUrl","hasLocale","getLocale","getWritingDirection","hasPermalink","getPermalink","hasDate","getDate","faqs","hasCustomData","getCustomData","hasTextTitle","isNil","getTextTitle","serialize","_parseClass","equals","paper","isEqual","parse","serialized","exports","default"],"sources":["../../../src/values/Paper.js"],"sourcesContent":["import {defaults, isEmpty, isEqual, isNil, isNull, isObject} from 'lodash';\nimport {cleanHTML} from '@axyseo/helpers';\nimport {transformRelatedKeyword} from '@axyseo/languageProcessing/researches/checkRelatedKeywords';\n\n/**\n * Default attributes to be used by the Paper if they are left undefined.\n * @type {{keyword: string, synonyms: string, description: string, title: string, titleWidth: number,\n * \t\t slug: string, locale: string, permalink: string, date: string, customData: object, textTitle: string,\n * \t\t writingDirection: \"LTR\", isFrontPage: boolean }}\n */\nconst defaultAttributes = {\n keyword: '',\n synonyms: '',\n description: '',\n title: '',\n titleWidth: 0,\n titleCount: null,\n h1Count: null,\n slug: '',\n domain: '',\n locale: 'en_US',\n permalink: '',\n date: '',\n customData: {},\n textTitle: '',\n writingDirection: 'LTR',\n wpBlocks: [],\n isFrontPage: false,\n pageType: '',\n};\n\n/**\n * Represents an object where the analysis data is stored.\n */\nexport default class Paper {\n /**\n * Constructs the Paper object and sets its attributes.\n *\n * @param {string} text The text to use in the analysis.\n * @param {object} [attributes] The object containing all attributes.\n * @param {string} [attributes.keyword] The main keyword or keyphrase of the text.\n * @param {string} [attributes.synonyms] The synonyms of the main keyword or keyphrase. It should be separated by commas if multiple synonyms are added.\n * @param {string} [attributes.description] The SEO meta description.\n * @param {string} [attributes.title] The SEO title.\n * @param {string} [attributes.domain] The shop domain.\n * @param {number|null} [attributes.titleCount=null] The title tag count value.\n * @param {number|null} [attributes.h1Count=null] The h1 tag count value.\n * @param {number} [attributes.titleWidth=0] The width of the title in pixels.\n * @param {string} [attributes.slug] The slug.\n * @param {string} [attributes.locale=en_US] The locale.\n * @param {string} [attributes.permalink] The full URL for any given post, page, or other pieces of content on a site.\n * @param {string} [attributes.date] The date.\n * @param {Object[]} [attributes.wpBlocks] The array of texts, encoded in WordPress block editor blocks.\n * @param {Object[]} [attributes.ignoredAssessments] The array of texts, show which assessments should be ignored.\n * @param {Object[]} [attributes.skippedAssessments] The array of texts, show which assessments should be skipped (those assessments will have good result).\n * @param {Object} [attributes.data] Given data.\n * @param {Object} [attributes.customData] Custom data.\n * @param {Object} [attributes.shopSettings] Shop's settings.\n * @param {string} [attributes.textTitle] The title of the text.\n * @param {string} [attributes.writingDirection=LTR] The writing direction of the paper. Defaults to left to right (LTR).\n * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.\n */\n constructor(text, attributes) {\n this._text = cleanHTML(text || '');\n\n this._tree = null;\n\n attributes = attributes || {};\n defaults(attributes, defaultAttributes);\n\n if (attributes.locale === '') {\n attributes.locale = defaultAttributes.locale;\n }\n\n if (attributes.hasOwnProperty('url')) {\n attributes.slug = attributes.url || attributes.slug;\n }\n\n const onlyLetters = attributes.keyword.replace(\n /[‘’“”\"'.?!:;,¿¡«»&*@#±^%|~`[\\](){}⟨⟩<>/\\\\–\\-\\u2014\\u00d7\\u002b\\s]/g,\n ''\n );\n\n if (isEmpty(onlyLetters)) {\n attributes.keyword = defaultAttributes.keyword;\n }\n\n this._attributes = attributes;\n }\n\n /**\n * Checks whether a keyword is available.\n * @returns {boolean} Returns true if the Paper has a keyword.\n */\n hasKeyword() {\n return this._attributes.keyword !== '';\n }\n\n /**\n * Returns the associated keyword or an empty string if no keyword is available.\n * @returns {string} Returns Keyword\n */\n getKeyword() {\n return this._attributes.keyword;\n }\n\n /**\n *\n * @returns {*|{keyword?: string, synonyms?: string, description?: string, title?: string, titleCount?: (number|null), h1Count?: (number|null), titleWidth?: number, slug?: string, locale?: string, permalink?: string, date?: string, wpBlocks?: Object[], customData?: Object, textTitle?: string, writingDirection?: string, isFrontPage?: boolean}|{}|{}}\n */\n getAttributes() {\n return this._attributes;\n }\n\n /**\n * Checks whether synonyms are available.\n * @returns {boolean} Returns true if the Paper has synonyms.\n */\n hasSynonyms() {\n return this._attributes.synonyms !== '';\n }\n\n /**\n * Returns the associated synonyms or an empty string if no synonyms is available.\n * @returns {string} Returns synonyms.\n */\n getSynonyms() {\n return this._attributes.synonyms;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getRelatedKeywords() {\n const data = this.getData();\n return (data?.related_keywords || []).map(keyword => keyword.text);\n }\n\n /**\n * Checks whether the h1 count value is available.\n * @returns {boolean} Returns true if the paper has a h1 count value.\n */\n hasH1Count() {\n return !isNull(this._attributes.h1Count);\n }\n\n /**\n * Returns the h1 tag count value.\n * @returns {number | null}\n */\n getH1Count() {\n return this._attributes.h1Count;\n }\n\n /**\n * Checks whether the title count value is available.\n * @returns {boolean} Returns true if the paper has a title count.\n */\n hasTitleCount() {\n return !isNull(this._attributes.titleCount);\n }\n\n /**\n * Returns the title count value.\n * @returns {number | null}\n */\n getTitleCount() {\n return this._attributes.titleCount;\n }\n\n /**\n * Checks whether the text is available.\n * @returns {boolean} Returns true if the paper has a text.\n */\n hasText() {\n return this._text !== '';\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getText() {\n return this._text;\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getDomain() {\n return this._attributes.domain;\n }\n\n /**\n * Sets the tree.\n *\n * @param {Node} tree The tree to set.\n *\n * @returns {void}\n */\n setTree(tree) {\n this._tree = tree;\n }\n\n /**\n * Returns the tree.\n *\n * @returns {Node} The tree.\n */\n getTree() {\n return this._tree;\n }\n\n /**\n * Checks whether a description is available.\n * @returns {boolean} Returns true if the paper has a description.\n */\n hasDescription() {\n return this._attributes.description !== '';\n }\n\n /**\n * Returns the description or an empty string if no description is available.\n * @returns {string} Returns the description.\n */\n getDescription() {\n return this._attributes.description;\n }\n\n /**\n * Checks whether an SEO title is available\n * @returns {boolean} Returns true if the Paper has an SEO title.\n */\n hasTitle() {\n return this._attributes.title !== '';\n }\n\n /**\n * Returns the SEO title, or an empty string if no title is available.\n * @returns {string} Returns the SEO title.\n */\n getTitle() {\n return this._attributes.title;\n }\n\n /**\n * Checks whether an SEO title width in pixels is available.\n * @returns {boolean} Returns true if the Paper's SEO title is wider than 0 pixels.\n */\n hasTitleWidth() {\n return this._attributes.titleWidth !== 0;\n }\n\n /**\n * Gets the SEO title width in pixels, or an empty string of no title width in pixels is available.\n * @returns {number} Returns the SEO title width in pixels.\n */\n getTitleWidth() {\n return this._attributes.titleWidth;\n }\n\n /**\n * Checks whether a slug is available.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasSlug() {\n return this._attributes.slug !== '';\n }\n\n /**\n * Checks whether a shop settings is available.\n * @returns {boolean} Returns true if the Paper has a shop settings.\n */\n hasShopSettings() {\n return !isEmpty(this._attributes?.shopSettings || {});\n }\n\n /**\n * Gets the paper's slug, or an empty string if no slug is available.\n * @returns {string} Returns the slug.\n */\n getSlug() {\n return this._attributes.slug;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasProductSchema() {\n return this._attributes?.hasProductSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasFAQsSchema() {\n return this._attributes?.hasFAQsSchema || false;\n }\n\n /**\n *\n * @returns {boolean}\n */\n hasFAQs() {\n return 'faqs' in this.getData() && this.getFAQs().length > 0;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasArticleSchema() {\n return this._attributes?.hasArticleSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasData() {\n const data = this._attributes?.data;\n return isObject(data) && !isEmpty(data);\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasRelatedKeywords() {\n const relatedKeywords = this._attributes?.data?.related_keywords || [];\n return Array.isArray(relatedKeywords) && relatedKeywords.length > 0;\n }\n\n /**\n *\n * @returns {Object|{}}\n */\n getData() {\n return this._attributes?.data || {};\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getIgnoredAssessments() {\n return this._attributes?.ignoredAssessments || [];\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getPageType() {\n return this._attributes?.pageType || '';\n }\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getSkippedAssessments() {\n return this._attributes?.skippedAssessments || [];\n }\n\n /**\n *\n * @returns {*|{}}\n */\n getShopSettings() {\n return this._attributes?.shopSettings || {};\n }\n\n /**\n * Checks if currently edited page is a front page.\n * @returns {boolean} Returns true if the current page is a front page.\n */\n isFrontPage() {\n return this._attributes.isFrontPage;\n }\n\n /**\n * Checks whether an url is available\n * @deprecated Since version 1.19.1. Use hasSlug instead.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasUrl() {\n console.warn('This function is deprecated, use hasSlug instead');\n return this.hasSlug();\n }\n\n /**\n * Returns the url, or an empty string if no url is available.\n * @deprecated Since version 1.19.1. Use getSlug instead.\n * @returns {string} Returns the url\n */\n getUrl() {\n console.warn('This function is deprecated, use getSlug instead');\n return this.getSlug();\n }\n\n /**\n * Checks whether a locale is available.\n * @returns {boolean} Returns true if the paper has a locale.\n */\n hasLocale() {\n return this._attributes.locale !== '';\n }\n\n /**\n * Returns the locale or an empty string if no locale is available\n * @returns {string} Returns the locale.\n */\n getLocale() {\n return this._attributes.locale;\n }\n\n /**\n * Gets the information of the writing direction of the paper.\n * It returns \"LTR\" (left to right) if this attribute is not provided.\n *\n * @returns {string} Returns the information of the writing direction of the paper.\n */\n getWritingDirection() {\n return this._attributes.writingDirection;\n }\n\n /**\n * Checks whether a permalink is available.\n * @returns {boolean} Returns true if the Paper has a permalink.\n */\n hasPermalink() {\n return this._attributes.permalink !== '';\n }\n\n /**\n * Returns the permalink, or an empty string if no permalink is available.\n * @returns {string} Returns the permalink.\n */\n getPermalink() {\n return this._attributes.permalink;\n }\n\n /**\n * Checks whether a date is available.\n * @returns {boolean} Returns true if the Paper has a date.\n */\n hasDate() {\n return this._attributes.date !== '';\n }\n\n /**\n * Returns the date, or an empty string if no date is available.\n * @returns {string} Returns the date.\n */\n getDate() {\n return this._attributes.date;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getFAQs() {\n return this.getData()?.faqs || {};\n }\n\n\n /**\n * Checks whether custom data is available.\n * @returns {boolean} Returns true if the Paper has custom data.\n */\n hasCustomData() {\n return !isEmpty(this._attributes.customData);\n }\n\n /**\n * Returns the custom data, or an empty object if no data is available.\n * @returns {Object} Returns the custom data.\n */\n getCustomData() {\n return this._attributes.customData;\n }\n\n /**\n * Checks whether a text title is available.\n * @returns {boolean} Returns true if the Paper has a text title.\n */\n hasTextTitle() {\n return this._attributes.textTitle !== '' && !isNil(this._attributes.textTitle);\n }\n\n /**\n * Returns the text title, or an empty string if no data is available.\n * @returns {string} Returns the text title.\n */\n getTextTitle() {\n return this._attributes.textTitle;\n }\n\n /**\n * Serializes the Paper instance to an object.\n *\n * @returns {Object} The serialized Paper.\n */\n serialize() {\n return {\n _parseClass: 'Paper',\n text: this._text,\n ...this._attributes\n };\n }\n\n /**\n * Checks whether the given paper has the same properties as this instance.\n *\n * @param {Paper} paper The paper to compare to.\n *\n * @returns {boolean} Whether the given paper is identical or not.\n */\n equals(paper) {\n return this._text === paper.getText() && isEqual(this._attributes, paper._attributes);\n }\n\n /**\n * Parses the object to a Paper.\n *\n * @param {Object|Paper} serialized The serialized object or Paper instance.\n *\n * @returns {Paper} The parsed Paper.\n */\n static parse(serialized) {\n // For ease of use, check if it is not already a Paper instance.\n if (serialized instanceof Paper) {\n return serialized;\n }\n\n // _parseClass is taken here, so it doesn't end up in the attributes.\n // eslint-disable-next-line no-unused-vars\n const {text, _parseClass, ...attributes} = serialized;\n\n return new Paper(text, attributes);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,iBAAiB,GAAG;EACxBC,OAAO,EAAE,EAAE;EACXC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,EAAE;EACfC,KAAK,EAAE,EAAE;EACTC,UAAU,EAAE,CAAC;EACbC,UAAU,EAAE,IAAI;EAChBC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,EAAE;EACRC,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE,OAAO;EACfC,SAAS,EAAE,EAAE;EACbC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,CAAC,CAAC;EACdC,SAAS,EAAE,EAAE;EACbC,gBAAgB,EAAE,KAAK;EACvBC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,KAAK;EAClBC,QAAQ,EAAE;AACZ,CAAC;;AAED;AACA;AACA;AACe,MAAMC,KAAK,CAAC;EACzB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,IAAI,EAAEC,UAAU,EAAE;IAC5B,IAAI,CAACC,KAAK,GAAG,IAAAC,kBAAS,EAACH,IAAI,IAAI,EAAE,CAAC;IAElC,IAAI,CAACI,KAAK,GAAG,IAAI;IAEjBH,UAAU,GAAGA,UAAU,IAAI,CAAC,CAAC;IAC7B,IAAAI,gB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d,OAAO,IAAI,CAAC/D,WAAW,CAACnB,UAAU;EACpC;;EAEA;AACF;AACA;AACA;EACEmF,YAAYA,CAAA,EAAG;IACb,OAAO,IAAI,CAAChE,WAAW,CAAClB,SAAS,KAAK,EAAE,IAAI,CAAC,IAAAmF,aAAK,EAAC,IAAI,CAACjE,WAAW,CAAClB,SAAS,CAAC;EAChF;;EAEA;AACF;AACA;AACA;EACEoF,YAAYA,CAAA,EAAG;IACb,OAAO,IAAI,CAAClE,WAAW,CAAClB,SAAS;EACnC;;EAEA;AACF;AACA;AACA;AACA;EACEqF,SAASA,CAAA,EAAG;IACV,OAAO;MACLC,WAAW,EAAE,OAAO;MACpB/E,IAAI,EAAE,IAAI,CAACE,KAAK;MAChB,GAAG,IAAI,CAACS;IACV,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEqE,MAAMA,CAACC,KAAK,EAAE;IACZ,OAAO,IAAI,CAAC/E,KAAK,KAAK+E,KAAK,CAACrD,OAAO,CAAC,CAAC,IAAI,IAAAsD,eAAO,EAAC,IAAI,CAACvE,WAAW,EAAEsE,KAAK,CAACtE,WAAW,CAAC;EACvF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,OAAOwE,KAAKA,CAACC,UAAU,EAAE;IACvB;IACA,IAAIA,UAAU,YAAYtF,KAAK,EAAE;MAC/B,OAAOsF,UAAU;IACnB;;IAEA;IACA;IACA,MAAM;MAACpF,IAAI;MAAE+E,WAAW;MAAE,GAAG9E;IAAU,CAAC,GAAGmF,UAAU;IAErD,OAAO,IAAItF,KAAK,CAACE,IAAI,EAAEC,UAAU,CAAC;EACpC;AACF;AAACoF,OAAA,CAAAC,OAAA,GAAAxF,KAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Paper.js","names":["_lodash","require","_helpers","_checkRelatedKeywords","defaultAttributes","keyword","synonyms","description","title","titleWidth","titleCount","h1Count","slug","domain","locale","permalink","date","customData","textTitle","writingDirection","wpBlocks","isFrontPage","pageType","Paper","constructor","text","attributes","_text","cleanHTML","_tree","defaults","hasOwnProperty","url","onlyLetters","replace","isEmpty","_attributes","hasKeyword","getKeyword","getAttributes","hasSynonyms","getSynonyms","getRelatedKeywords","data","getData","related_keywords","map","hasH1Count","isNull","getH1Count","hasTitleCount","getTitleCount","hasText","getText","getDomain","setTree","tree","getTree","hasDescription","body_html","descriptionHtml","getDescription","hasTitle","getTitle","hasTitleWidth","getTitleWidth","hasSlug","hasShopSettings","shopSettings","getSlug","hasProductSchema","hasFAQsSchema","hasFAQs","getFAQs","length","hasArticleSchema","hasData","isObject","hasRelatedKeywords","relatedKeywords","Array","isArray","getIgnoredAssessments","ignoredAssessments","getPageType","getSkippedAssessments","skippedAssessments","getShopSettings","hasUrl","console","warn","getUrl","hasLocale","getLocale","getWritingDirection","hasPermalink","getPermalink","hasDate","getDate","faqs","hasCustomData","getCustomData","hasTextTitle","isNil","getTextTitle","serialize","_parseClass","equals","paper","isEqual","parse","serialized","exports","default"],"sources":["../../../src/values/Paper.js"],"sourcesContent":["import {defaults, isEmpty, isEqual, isNil, isNull, isObject} from 'lodash';\nimport {cleanHTML} from '@axyseo/helpers';\nimport {transformRelatedKeyword} from '@axyseo/languageProcessing/researches/checkRelatedKeywords';\n\n/**\n * Default attributes to be used by the Paper if they are left undefined.\n * @type {{keyword: string, synonyms: string, description: string, title: string, titleWidth: number,\n * \t\t slug: string, locale: string, permalink: string, date: string, customData: object, textTitle: string,\n * \t\t writingDirection: \"LTR\", isFrontPage: boolean }}\n */\nconst defaultAttributes = {\n keyword: '',\n synonyms: '',\n description: '',\n title: '',\n titleWidth: 0,\n titleCount: null,\n h1Count: null,\n slug: '',\n domain: '',\n locale: 'en_US',\n permalink: '',\n date: '',\n customData: {},\n textTitle: '',\n writingDirection: 'LTR',\n wpBlocks: [],\n isFrontPage: false,\n pageType: '',\n};\n\n/**\n * Represents an object where the analysis data is stored.\n */\nexport default class Paper {\n /**\n * Constructs the Paper object and sets its attributes.\n *\n * @param {string} text The text to use in the analysis.\n * @param {object} [attributes] The object containing all attributes.\n * @param {string} [attributes.keyword] The main keyword or keyphrase of the text.\n * @param {string} [attributes.synonyms] The synonyms of the main keyword or keyphrase. It should be separated by commas if multiple synonyms are added.\n * @param {string} [attributes.description] The SEO meta description.\n * @param {string} [attributes.title] The SEO title.\n * @param {string} [attributes.domain] The shop domain.\n * @param {number|null} [attributes.titleCount=null] The title tag count value.\n * @param {number|null} [attributes.h1Count=null] The h1 tag count value.\n * @param {number} [attributes.titleWidth=0] The width of the title in pixels.\n * @param {string} [attributes.slug] The slug.\n * @param {string} [attributes.locale=en_US] The locale.\n * @param {string} [attributes.permalink] The full URL for any given post, page, or other pieces of content on a site.\n * @param {string} [attributes.date] The date.\n * @param {Object[]} [attributes.wpBlocks] The array of texts, encoded in WordPress block editor blocks.\n * @param {Object[]} [attributes.ignoredAssessments] The array of texts, show which assessments should be ignored.\n * @param {Object[]} [attributes.skippedAssessments] The array of texts, show which assessments should be skipped (those assessments will have good result).\n * @param {Object} [attributes.data] Given data.\n * @param {Object} [attributes.customData] Custom data.\n * @param {Object} [attributes.shopSettings] Shop's settings.\n * @param {string} [attributes.textTitle] The title of the text.\n * @param {string} [attributes.writingDirection=LTR] The writing direction of the paper. Defaults to left to right (LTR).\n * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.\n */\n constructor(text, attributes) {\n this._text = cleanHTML(text || '');\n\n this._tree = null;\n\n attributes = attributes || {};\n defaults(attributes, defaultAttributes);\n\n if (attributes.locale === '') {\n attributes.locale = defaultAttributes.locale;\n }\n\n if (attributes.hasOwnProperty('url')) {\n attributes.slug = attributes.url || attributes.slug;\n }\n\n const onlyLetters = attributes.keyword.replace(\n /[‘’“”\"'.?!:;,¿¡«»&*@#±^%|~`[\\](){}⟨⟩<>/\\\\–\\-\\u2014\\u00d7\\u002b\\s]/g,\n ''\n );\n\n if (isEmpty(onlyLetters)) {\n attributes.keyword = defaultAttributes.keyword;\n }\n\n this._attributes = attributes;\n }\n\n /**\n * Checks whether a keyword is available.\n * @returns {boolean} Returns true if the Paper has a keyword.\n */\n hasKeyword() {\n return this._attributes.keyword !== '';\n }\n\n /**\n * Returns the associated keyword or an empty string if no keyword is available.\n * @returns {string} Returns Keyword\n */\n getKeyword() {\n return this._attributes.keyword;\n }\n\n /**\n *\n * @returns {*|{keyword?: string, synonyms?: string, description?: string, title?: string, titleCount?: (number|null), h1Count?: (number|null), titleWidth?: number, slug?: string, locale?: string, permalink?: string, date?: string, wpBlocks?: Object[], customData?: Object, textTitle?: string, writingDirection?: string, isFrontPage?: boolean}|{}|{}}\n */\n getAttributes() {\n return this._attributes;\n }\n\n /**\n * Checks whether synonyms are available.\n * @returns {boolean} Returns true if the Paper has synonyms.\n */\n hasSynonyms() {\n return this._attributes.synonyms !== '';\n }\n\n /**\n * Returns the associated synonyms or an empty string if no synonyms is available.\n * @returns {string} Returns synonyms.\n */\n getSynonyms() {\n return this._attributes.synonyms;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getRelatedKeywords() {\n const data = this.getData();\n return (data?.related_keywords || []).map(keyword => keyword.text);\n }\n\n /**\n * Checks whether the h1 count value is available.\n * @returns {boolean} Returns true if the paper has a h1 count value.\n */\n hasH1Count() {\n return !isNull(this._attributes.h1Count);\n }\n\n /**\n * Returns the h1 tag count value.\n * @returns {number | null}\n */\n getH1Count() {\n return this._attributes.h1Count;\n }\n\n /**\n * Checks whether the title count value is available.\n * @returns {boolean} Returns true if the paper has a title count.\n */\n hasTitleCount() {\n return !isNull(this._attributes.titleCount);\n }\n\n /**\n * Returns the title count value.\n * @returns {number | null}\n */\n getTitleCount() {\n return this._attributes.titleCount;\n }\n\n /**\n * Checks whether the text is available.\n * @returns {boolean} Returns true if the paper has a text.\n */\n hasText() {\n return this._text !== '';\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getText() {\n return this._text;\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getDomain() {\n return this._attributes.domain;\n }\n\n /**\n * Sets the tree.\n *\n * @param {Node} tree The tree to set.\n *\n * @returns {void}\n */\n setTree(tree) {\n this._tree = tree;\n }\n\n /**\n * Returns the tree.\n *\n * @returns {Node} The tree.\n */\n getTree() {\n return this._tree;\n }\n\n /**\n * Checks whether a description is available.\n * @returns {boolean} Returns true if the paper has a description.\n */\n hasDescription() {\n return this._attributes?.data?.body_html !== '' || this._attributes?.data?.descriptionHtml !== '';\n }\n\n /**\n * Returns the description or an empty string if no description is available.\n * @returns {string} Returns the description.\n */\n getDescription() {\n return this._attributes.description;\n }\n\n /**\n * Checks whether an SEO title is available\n * @returns {boolean} Returns true if the Paper has an SEO title.\n */\n hasTitle() {\n return this._attributes.title !== '';\n }\n\n /**\n * Returns the SEO title, or an empty string if no title is available.\n * @returns {string} Returns the SEO title.\n */\n getTitle() {\n return this._attributes.title;\n }\n\n /**\n * Checks whether an SEO title width in pixels is available.\n * @returns {boolean} Returns true if the Paper's SEO title is wider than 0 pixels.\n */\n hasTitleWidth() {\n return this._attributes.titleWidth !== 0;\n }\n\n /**\n * Gets the SEO title width in pixels, or an empty string of no title width in pixels is available.\n * @returns {number} Returns the SEO title width in pixels.\n */\n getTitleWidth() {\n return this._attributes.titleWidth;\n }\n\n /**\n * Checks whether a slug is available.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasSlug() {\n return this._attributes.slug !== '';\n }\n\n /**\n * Checks whether a shop settings is available.\n * @returns {boolean} Returns true if the Paper has a shop settings.\n */\n hasShopSettings() {\n return !isEmpty(this._attributes?.shopSettings || {});\n }\n\n /**\n * Gets the paper's slug, or an empty string if no slug is available.\n * @returns {string} Returns the slug.\n */\n getSlug() {\n return this._attributes.slug;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasProductSchema() {\n return this._attributes?.hasProductSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasFAQsSchema() {\n return this._attributes?.hasFAQsSchema || false;\n }\n\n /**\n *\n * @returns {boolean}\n */\n hasFAQs() {\n return 'faqs' in this.getData() && this.getFAQs().length > 0;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasArticleSchema() {\n return this._attributes?.hasArticleSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasData() {\n const data = this._attributes?.data;\n return isObject(data) && !isEmpty(data);\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasRelatedKeywords() {\n const relatedKeywords = this._attributes?.data?.related_keywords || [];\n return Array.isArray(relatedKeywords) && relatedKeywords.length > 0;\n }\n\n /**\n *\n * @returns {Object|{}}\n */\n getData() {\n return this._attributes?.data || {};\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getIgnoredAssessments() {\n return this._attributes?.ignoredAssessments || [];\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getPageType() {\n return this._attributes?.pageType || '';\n }\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getSkippedAssessments() {\n return this._attributes?.skippedAssessments || [];\n }\n\n /**\n *\n * @returns {*|{}}\n */\n getShopSettings() {\n return this._attributes?.shopSettings || {};\n }\n\n /**\n * Checks if currently edited page is a front page.\n * @returns {boolean} Returns true if the current page is a front page.\n */\n isFrontPage() {\n return this._attributes.isFrontPage;\n }\n\n /**\n * Checks whether an url is available\n * @deprecated Since version 1.19.1. Use hasSlug instead.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasUrl() {\n console.warn('This function is deprecated, use hasSlug instead');\n return this.hasSlug();\n }\n\n /**\n * Returns the url, or an empty string if no url is available.\n * @deprecated Since version 1.19.1. Use getSlug instead.\n * @returns {string} Returns the url\n */\n getUrl() {\n console.warn('This function is deprecated, use getSlug instead');\n return this.getSlug();\n }\n\n /**\n * Checks whether a locale is available.\n * @returns {boolean} Returns true if the paper has a locale.\n */\n hasLocale() {\n return this._attributes.locale !== '';\n }\n\n /**\n * Returns the locale or an empty string if no locale is available\n * @returns {string} Returns the locale.\n */\n getLocale() {\n return this._attributes.locale;\n }\n\n /**\n * Gets the information of the writing direction of the paper.\n * It returns \"LTR\" (left to right) if this attribute is not provided.\n *\n * @returns {string} Returns the information of the writing direction of the paper.\n */\n getWritingDirection() {\n return this._attributes.writingDirection;\n }\n\n /**\n * Checks whether a permalink is available.\n * @returns {boolean} Returns true if the Paper has a permalink.\n */\n hasPermalink() {\n return this._attributes.permalink !== '';\n }\n\n /**\n * Returns the permalink, or an empty string if no permalink is available.\n * @returns {string} Returns the permalink.\n */\n getPermalink() {\n return this._attributes.permalink;\n }\n\n /**\n * Checks whether a date is available.\n * @returns {boolean} Returns true if the Paper has a date.\n */\n hasDate() {\n return this._attributes.date !== '';\n }\n\n /**\n * Returns the date, or an empty string if no date is available.\n * @returns {string} Returns the date.\n */\n getDate() {\n return this._attributes.date;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getFAQs() {\n return this.getData()?.faqs || {};\n }\n\n\n /**\n * Checks whether custom data is available.\n * @returns {boolean} Returns true if the Paper has custom data.\n */\n hasCustomData() {\n return !isEmpty(this._attributes.customData);\n }\n\n /**\n * Returns the custom data, or an empty object if no data is available.\n * @returns {Object} Returns the custom data.\n */\n getCustomData() {\n return this._attributes.customData;\n }\n\n /**\n * Checks whether a text title is available.\n * @returns {boolean} Returns true if the Paper has a text title.\n */\n hasTextTitle() {\n return this._attributes.textTitle !== '' && !isNil(this._attributes.textTitle);\n }\n\n /**\n * Returns the text title, or an empty string if no data is available.\n * @returns {string} Returns the text title.\n */\n getTextTitle() {\n return this._attributes.textTitle;\n }\n\n /**\n * Serializes the Paper instance to an object.\n *\n * @returns {Object} The serialized Paper.\n */\n serialize() {\n return {\n _parseClass: 'Paper',\n text: this._text,\n ...this._attributes\n };\n }\n\n /**\n * Checks whether the given paper has the same properties as this instance.\n *\n * @param {Paper} paper The paper to compare to.\n *\n * @returns {boolean} Whether the given paper is identical or not.\n */\n equals(paper) {\n return this._text === paper.getText() && isEqual(this._attributes, paper._attributes);\n }\n\n /**\n * Parses the object to a Paper.\n *\n * @param {Object|Paper} serialized The serialized object or Paper instance.\n *\n * @returns {Paper} The parsed Paper.\n */\n static parse(serialized) {\n // For ease of use, check if it is not already a Paper instance.\n if (serialized instanceof Paper) {\n return serialized;\n }\n\n // _parseClass is taken here, so it doesn't end up in the attributes.\n // eslint-disable-next-line no-unused-vars\n const {text, _parseClass, ...attributes} = serialized;\n\n return new Paper(text, attributes);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,iBAAiB,GAAG;EACxBC,OAAO,EAAE,EAAE;EACXC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,EAAE;EACfC,KAAK,EAAE,EAAE;EACTC,UAAU,EAAE,CAAC;EACbC,UAAU,EAAE,IAAI;EAChBC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,EAAE;EACRC,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE,OAAO;EACfC,SAAS,EAAE,EAAE;EACbC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,CAAC,CAAC;EACdC,SAAS,EAAE,EAAE;EACbC,gBAAgB,EAAE,KAAK;EACvBC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,KAAK;EAClBC,QAAQ,EAAE;AACZ,CAAC;;AAED;AACA;AACA;AACe,MAAMC,KAAK,CAAC;EACzB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,IAAI,EAAEC,UAAU,EAAE;IAC5B,IAAI,CAACC,KAAK,GAAG,IAAAC,kBAAS,EAACH,IAAI,IAAI,EAAE,C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AA1F,KAAA","ignoreList":[]}
|
|
@@ -5,6 +5,12 @@ import { getParentNode } from "../helpers/sentence/getSentencesFromTree";
|
|
|
5
5
|
import { createShortcodeTagsRegex } from "../helpers";
|
|
6
6
|
import isChineseText from "../helpers/language/isChineseText";
|
|
7
7
|
|
|
8
|
+
// Matches common UI-marker class names (label, eyebrow, kicker, etc.) used for
|
|
9
|
+
// short text placed above a heading. Anchored to the start, with a boundary so
|
|
10
|
+
// `header-label` or `tagline` don't match.
|
|
11
|
+
const LABEL_LIKE_CLASS_REGEX = /^(label|eyebrow|kicker|overline|pretitle|subtitle|badge|tag|chip|meta|category|breadcrumb)(\b|[-_])/i;
|
|
12
|
+
const MIN_INTRO_WORDS = 5;
|
|
13
|
+
|
|
8
14
|
/**
|
|
9
15
|
* Checks if the introductory paragraph contains keyphrase or synonyms.
|
|
10
16
|
* First splits the first paragraph by sentences. Finds the first paragraph which contains sentences e.g., not an image).
|
|
@@ -35,6 +41,21 @@ export default function (paper, researcher) {
|
|
|
35
41
|
paragraphs = paragraphs.filter(paragraph => {
|
|
36
42
|
return !(paragraph.childNodes && paragraph.childNodes[0] && createShortcodeTagsRegex(['caption']).test(paragraph.childNodes[0].value));
|
|
37
43
|
});
|
|
44
|
+
// Filter UI label/eyebrow/kicker paragraphs that sit before the heading
|
|
45
|
+
// (e.g., <p class="label">CATEGORY</p>). These are visual markers, not real
|
|
46
|
+
// intro paragraphs, and would cause false negatives on keyword-in-intro checks.
|
|
47
|
+
paragraphs = paragraphs.filter(paragraph => {
|
|
48
|
+
const classSet = paragraph.attributes && paragraph.attributes.class;
|
|
49
|
+
if (classSet instanceof Set) {
|
|
50
|
+
for (const cls of classSet) {
|
|
51
|
+
if (LABEL_LIKE_CLASS_REGEX.test(cls)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const wordCount = (paragraph.innerText() || '').trim().split(/\s+/).filter(Boolean).length;
|
|
57
|
+
return wordCount >= MIN_INTRO_WORDS;
|
|
58
|
+
});
|
|
38
59
|
const firstParagraph = paragraphs[0];
|
|
39
60
|
const topicForms = researcher.getResearch('morphology');
|
|
40
61
|
let matchWordCustomHelper = researcher.getHelper('matchWordCustomHelper');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findKeywordInFirstParagraph.js","names":["inRange","isEmpty","findTopicFormsInString","getParentNode","createShortcodeTagsRegex","isChineseText","paper","researcher","paragraphs","getResearch","filter","paragraph","parentNode","isImplicit","name","childNodes","test","value","firstParagraph","topicForms","matchWordCustomHelper","getHelper","locale","getLocale","getKeyword","innerText","text","word","textToSearch","matches","lowerText","toLowerCase","lowerWord","startIndex","index","indexOf","push","length","startOffset","sourceCodeLocation","mappedBlocks","_attributes","wpBlocks","filteredIntroductionBlock","block","endOffset","result","foundInOneSentence","foundInParagraph","keyphraseOrSynonym","introduction","parentBlock","sentences","map","sentence","useSynonyms","firstResultSentence","find","resultSentence","percentWordMatches","resultParagraph"],"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';\nimport isChineseText from '../helpers/language/isChineseText';\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 let matchWordCustomHelper = researcher.getHelper('matchWordCustomHelper');\n const locale = paper.getLocale();\n\n // Auto-detect Chinese and use Chinese helper if not already available\n if (\n !matchWordCustomHelper &&\n isChineseText(paper.getKeyword() + ' ' + (firstParagraph ? firstParagraph.innerText() : ''))\n ) {\n // Use Chinese word matching for Chinese text\n matchWordCustomHelper = function(text, word) {\n const textToSearch = typeof text === 'string' ? text : text.text || text;\n const matches = [];\n\n if (!textToSearch || !word) {\n return matches;\n }\n\n const lowerText = textToSearch.toLowerCase();\n const lowerWord = word.toLowerCase();\n\n let startIndex = 0;\n let index;\n\n while ((index = lowerText.indexOf(lowerWord, startIndex)) !== -1) {\n matches.push(word);\n startIndex = index + lowerWord.length;\n }\n\n return matches;\n };\n }\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;AAChC,OAAOC,aAAa;;AAEpB;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,GAAGT,aAAa,CAACG,KAAK,EAAEK,SAAS,CAAC;IAClD,OAAO,EAAEA,SAAS,CAACE,UAAU,IAAID,UAAU,IAAIA,UAAU,CAACE,IAA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AAM,CAACC,kBAAkB,GAAG,IAAI;MAChCD,MAAM,CAACE,gBAAgB,GAAG,IAAI;MAC9BF,MAAM,CAACG,kBAAkB,GAAGO,mBAAmB,CAACP,kBAAkB;MAClE,OAAOH,MAAM;IACf;IAEA,MAAMc,eAAe,GAAG1D,sBAAsB,CAC5CiB,UAAU,EACVD,cAAc,CAACO,SAAS,CAAC,CAAC,EAC1B8B,WAAW,EACXjC,MAAM,EACNF,qBACF,CAAC;IACD,IAAIwC,eAAe,CAACD,kBAAkB,KAAK,GAAG,EAAE;MAC9Cb,MAAM,CAACE,gBAAgB,GAAG,IAAI;MAC9BF,MAAM,CAACG,kBAAkB,GAAGW,eAAe,CAACX,kBAAkB;MAC9D,OAAOH,MAAM;IACf;EACF;EAEA,OAAOA,MAAM;AACf","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"findKeywordInFirstParagraph.js","names":["inRange","isEmpty","findTopicFormsInString","getParentNode","createShortcodeTagsRegex","isChineseText","LABEL_LIKE_CLASS_REGEX","MIN_INTRO_WORDS","paper","researcher","paragraphs","getResearch","filter","paragraph","parentNode","isImplicit","name","childNodes","test","value","classSet","attributes","class","Set","cls","wordCount","innerText","trim","split","Boolean","length","firstParagraph","topicForms","matchWordCustomHelper","getHelper","locale","getLocale","getKeyword","text","word","textToSearch","matches","lowerText","toLowerCase","lowerWord","startIndex","index","indexOf","push","startOffset","sourceCodeLocation","mappedBlocks","_attributes","wpBlocks","filteredIntroductionBlock","block","endOffset","result","foundInOneSentence","foundInParagraph","keyphraseOrSynonym","introduction","parentBlock","sentences","map","sentence","useSynonyms","firstResultSentence","find","resultSentence","percentWordMatches","resultParagraph"],"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';\nimport isChineseText from '../helpers/language/isChineseText';\n\n// Matches common UI-marker class names (label, eyebrow, kicker, etc.) used for\n// short text placed above a heading. Anchored to the start, with a boundary so\n// `header-label` or `tagline` don't match.\nconst LABEL_LIKE_CLASS_REGEX = /^(label|eyebrow|kicker|overline|pretitle|subtitle|badge|tag|chip|meta|category|breadcrumb)(\\b|[-_])/i;\nconst MIN_INTRO_WORDS = 5;\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 // Filter UI label/eyebrow/kicker paragraphs that sit before the heading\n // (e.g., <p class=\"label\">CATEGORY</p>). These are visual markers, not real\n // intro paragraphs, and would cause false negatives on keyword-in-intro checks.\n paragraphs = paragraphs.filter(paragraph => {\n const classSet = paragraph.attributes && paragraph.attributes.class;\n if (classSet instanceof Set) {\n for (const cls of classSet) {\n if (LABEL_LIKE_CLASS_REGEX.test(cls)) {\n return false;\n }\n }\n }\n const wordCount = (paragraph.innerText() || '')\n .trim()\n .split(/\\s+/)\n .filter(Boolean).length;\n return wordCount >= MIN_INTRO_WORDS;\n });\n const firstParagraph = paragraphs[0];\n\n const topicForms = researcher.getResearch('morphology');\n let matchWordCustomHelper = researcher.getHelper('matchWordCustomHelper');\n const locale = paper.getLocale();\n\n // Auto-detect Chinese and use Chinese helper if not already available\n if (\n !matchWordCustomHelper &&\n isChineseText(paper.getKeyword() + ' ' + (firstParagraph ? firstParagraph.innerText() : ''))\n ) {\n // Use Chinese word matching for Chinese text\n matchWordCustomHelper = function(text, word) {\n const textToSearch = typeof text === 'string' ? text : text.text || text;\n const matches = [];\n\n if (!textToSearch || !word) {\n return matches;\n }\n\n const lowerText = textToSearch.toLowerCase();\n const lowerWord = word.toLowerCase();\n\n let startIndex = 0;\n let index;\n\n while ((index = lowerText.indexOf(lowerWord, startIndex)) !== -1) {\n matches.push(word);\n startIndex = index + lowerWord.length;\n }\n\n return matches;\n };\n }\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;AAChC,OAAOC,aAAa;;AAEpB;AACA;AACA;AACA,MAAMC,sBAAsB,GAAG,sGAAsG;AACrI,MAAMC,eAAe,GAAG,CAAC;;AAEzB;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,GAAGX,aAAa,CAACK,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,U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AACC,GAAG,CAACC,QAAQ,IAAIA,QAAQ,CAAC3B,IAAI,CAAC;EACzE;EACA,MAAM4B,WAAW,GAAG,IAAI;EAExB,IAAI,CAACjE,OAAO,CAAC8D,SAAS,CAAC,EAAE;IACvB,MAAMI,mBAAmB,GAAGJ,SAAS,CAClCC,GAAG,CAACC,QAAQ,IACX/D,sBAAsB,CAAC8B,UAAU,EAAEiC,QAAQ,EAAEC,WAAW,EAAE/B,MAAM,EAAEF,qBAAqB,CACzF,CAAC,CACAmC,IAAI,CAACC,cAAc,IAAIA,cAAc,CAACC,kBAAkB,KAAK,GAAG,CAAC;IAEpE,IAAIH,mBAAmB,EAAE;MACvBV,MAAM,CAACC,kBAAkB,GAAG,IAAI;MAChCD,MAAM,CAACE,gBAAgB,GAAG,IAAI;MAC9BF,MAAM,CAACG,kBAAkB,GAAGO,mBAAmB,CAACP,kBAAkB;MAClE,OAAOH,MAAM;IACf;IAEA,MAAMc,eAAe,GAAGrE,sBAAsB,CAC5C8B,UAAU,EACVD,cAAc,CAACL,SAAS,CAAC,CAAC,EAC1BwC,WAAW,EACX/B,MAAM,EACNF,qBACF,CAAC;IACD,IAAIsC,eAAe,CAACD,kBAAkB,KAAK,GAAG,EAAE;MAC9Cb,MAAM,CAACE,gBAAgB,GAAG,IAAI;MAC9BF,MAAM,CAACG,kBAAkB,GAAGW,eAAe,CAACX,kBAAkB;MAC9D,OAAOH,MAAM;IACf;EACF;EAEA,OAAOA,MAAM;AACf","ignoreList":[]}
|
|
@@ -46,7 +46,6 @@ export default class RelatedKeywordsDensityAssessment extends Assessment {
|
|
|
46
46
|
} = relatedKeywords;
|
|
47
47
|
let status = 'good';
|
|
48
48
|
const totalWords = Object.values(words).filter(word => word.percentage === 0);
|
|
49
|
-
console.log("Related keyword density check: ", !hasDescription, isEmpty(words), totalWords.length > 0);
|
|
50
49
|
if (!hasDescription || isEmpty(words) || totalWords.length > 0) {
|
|
51
50
|
status = 'bad';
|
|
52
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelatedKeywordsDensityAssessment.js","names":["isEmpty","merge","AssessmentResult","Assessment","MAIN_CONTENT_POINTS","RELATED_KEYWORDS_DENSITY_ID","RelatedKeywordsDensityAssessment","constructor","config","defaultConfig","id","fixPosition","ctaType","docUrl","priority","title","content","good","bad","improve","identifier","_config","calculateResult","data","relatedKeywords","hasDescription","words","status","totalWords","Object","values","filter","word","percentage","
|
|
1
|
+
{"version":3,"file":"RelatedKeywordsDensityAssessment.js","names":["isEmpty","merge","AssessmentResult","Assessment","MAIN_CONTENT_POINTS","RELATED_KEYWORDS_DENSITY_ID","RelatedKeywordsDensityAssessment","constructor","config","defaultConfig","id","fixPosition","ctaType","docUrl","priority","title","content","good","bad","improve","identifier","_config","calculateResult","data","relatedKeywords","hasDescription","words","status","totalWords","Object","values","filter","word","percentage","length","score","getScore","getResult","paper","researcher","getResearch","getData","result","assessmentResult","setScore","setStatus","setData","isApplicable"],"sources":["../../../../../src/scoring/assessments/seo/RelatedKeywordsDensityAssessment.js"],"sourcesContent":["import {isEmpty, merge} from 'lodash';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\nimport {MAIN_CONTENT_POINTS, RELATED_KEYWORDS_DENSITY_ID} from '@axyseo/const/analysis';\n\n/**\n * Represents the assessment that checks whether there are enough transition words in the text.\n */\nexport default class RelatedKeywordsDensityAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {object} config The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: RELATED_KEYWORDS_DENSITY_ID,\n fixPosition: 'description',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#related-keywords',\n priority: 'high',\n title: 'Related keywords density',\n content: {\n good: 'Related keywords density optimized',\n bad:\n 'Use each secondary keyword from 0.5% to 1%. Place where it reads naturally.',\n improve: ''\n }\n };\n\n this.identifier = RELATED_KEYWORDS_DENSITY_ID;\n this._config = merge(defaultConfig, config);\n }\n\n /**\n *\n * @param data\n * @param relatedKeywords\n * @param hasDescription\n * @returns {{score: number, status: string, words}}\n */\n calculateResult(data, relatedKeywords, hasDescription) {\n const {words} = relatedKeywords;\n let status = 'good';\n const totalWords = Object.values(words).filter(word => word.percentage === 0);\n if(!hasDescription || isEmpty(words) || totalWords.length > 0){\n status = 'bad';\n }\n const score = this.getScore(MAIN_CONTENT_POINTS, status);\n\n return {\n score,\n status,\n words\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher}) {\n const relatedKeywords = researcher.getResearch('checkRelatedKeywords');\n const data = paper.getData();\n const hasDescription = paper.hasDescription();\n const result = this.calculateResult(data, relatedKeywords, hasDescription);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(result.score);\n assessmentResult.setStatus(result.status);\n assessmentResult.setData(result.words);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the transition words assessment is applicable to the paper. Language-specific length requirements and methods of counting text length\n * may apply (e.g. for Japanese, the text should be counted in characters instead of words, which also makes the minimum required length higher).\n *\n * @param {Paper} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available, the paper is not empty and the text is longer than the minimum required length.\n */\n isApplicable(paper, researcher) {\n return true;\n }\n}\n"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,KAAK,QAAO,QAAQ;AACrC,OAAOC,gBAAgB;AACvB,OAAOC,UAAU;AACjB,SAAQC,mBAAmB,EAAEC,2BAA2B;;AAExD;AACA;AACA;AACA,eAAe,MAAMC,gCAAgC,SAASH,UAAU,CAAC;EACvE;AACF;AACA;AACA;AACA;AACA;AACA;EACEI,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAEL,2BAA2B;MAC/BM,W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ACpB,eAAe,CAACC,IAAI,EAAEC,eAAe,EAAEC,cAAc,CAAC;IAC1E,MAAMkB,gBAAgB,GAAG,IAAIzC,gBAAgB,CAAC;MAACM,MAAM,EAAE,IAAI,CAACa;IAAO,CAAC,CAAC;IAErEsB,gBAAgB,CAACC,QAAQ,CAACF,MAAM,CAACP,KAAK,CAAC;IACvCQ,gBAAgB,CAACE,SAAS,CAACH,MAAM,CAACf,MAAM,CAAC;IACzCgB,gBAAgB,CAACG,OAAO,CAACJ,MAAM,CAAChB,KAAK,CAAC;IAEtC,OAAOiB,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEI,YAAYA,CAACT,KAAK,EAAEC,UAAU,EAAE;IAC9B,OAAO,IAAI;EACb;AACF","ignoreList":[]}
|
|
@@ -208,7 +208,7 @@ export default class Paper {
|
|
|
208
208
|
* @returns {boolean} Returns true if the paper has a description.
|
|
209
209
|
*/
|
|
210
210
|
hasDescription() {
|
|
211
|
-
return this._attributes.
|
|
211
|
+
return this._attributes?.data?.body_html !== '' || this._attributes?.data?.descriptionHtml !== '';
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Paper.js","names":["defaults","isEmpty","isEqual","isNil","isNull","isObject","cleanHTML","transformRelatedKeyword","defaultAttributes","keyword","synonyms","description","title","titleWidth","titleCount","h1Count","slug","domain","locale","permalink","date","customData","textTitle","writingDirection","wpBlocks","isFrontPage","pageType","Paper","constructor","text","attributes","_text","_tree","hasOwnProperty","url","onlyLetters","replace","_attributes","hasKeyword","getKeyword","getAttributes","hasSynonyms","getSynonyms","getRelatedKeywords","data","getData","related_keywords","map","hasH1Count","getH1Count","hasTitleCount","getTitleCount","hasText","getText","getDomain","setTree","tree","getTree","hasDescription","getDescription","hasTitle","getTitle","hasTitleWidth","getTitleWidth","hasSlug","hasShopSettings","shopSettings","getSlug","hasProductSchema","hasFAQsSchema","hasFAQs","getFAQs","length","hasArticleSchema","hasData","hasRelatedKeywords","relatedKeywords","Array","isArray","getIgnoredAssessments","ignoredAssessments","getPageType","getSkippedAssessments","skippedAssessments","getShopSettings","hasUrl","console","warn","getUrl","hasLocale","getLocale","getWritingDirection","hasPermalink","getPermalink","hasDate","getDate","faqs","hasCustomData","getCustomData","hasTextTitle","getTextTitle","serialize","_parseClass","equals","paper","parse","serialized"],"sources":["../../../src/values/Paper.js"],"sourcesContent":["import {defaults, isEmpty, isEqual, isNil, isNull, isObject} from 'lodash';\nimport {cleanHTML} from '@axyseo/helpers';\nimport {transformRelatedKeyword} from '@axyseo/languageProcessing/researches/checkRelatedKeywords';\n\n/**\n * Default attributes to be used by the Paper if they are left undefined.\n * @type {{keyword: string, synonyms: string, description: string, title: string, titleWidth: number,\n * \t\t slug: string, locale: string, permalink: string, date: string, customData: object, textTitle: string,\n * \t\t writingDirection: \"LTR\", isFrontPage: boolean }}\n */\nconst defaultAttributes = {\n keyword: '',\n synonyms: '',\n description: '',\n title: '',\n titleWidth: 0,\n titleCount: null,\n h1Count: null,\n slug: '',\n domain: '',\n locale: 'en_US',\n permalink: '',\n date: '',\n customData: {},\n textTitle: '',\n writingDirection: 'LTR',\n wpBlocks: [],\n isFrontPage: false,\n pageType: '',\n};\n\n/**\n * Represents an object where the analysis data is stored.\n */\nexport default class Paper {\n /**\n * Constructs the Paper object and sets its attributes.\n *\n * @param {string} text The text to use in the analysis.\n * @param {object} [attributes] The object containing all attributes.\n * @param {string} [attributes.keyword] The main keyword or keyphrase of the text.\n * @param {string} [attributes.synonyms] The synonyms of the main keyword or keyphrase. It should be separated by commas if multiple synonyms are added.\n * @param {string} [attributes.description] The SEO meta description.\n * @param {string} [attributes.title] The SEO title.\n * @param {string} [attributes.domain] The shop domain.\n * @param {number|null} [attributes.titleCount=null] The title tag count value.\n * @param {number|null} [attributes.h1Count=null] The h1 tag count value.\n * @param {number} [attributes.titleWidth=0] The width of the title in pixels.\n * @param {string} [attributes.slug] The slug.\n * @param {string} [attributes.locale=en_US] The locale.\n * @param {string} [attributes.permalink] The full URL for any given post, page, or other pieces of content on a site.\n * @param {string} [attributes.date] The date.\n * @param {Object[]} [attributes.wpBlocks] The array of texts, encoded in WordPress block editor blocks.\n * @param {Object[]} [attributes.ignoredAssessments] The array of texts, show which assessments should be ignored.\n * @param {Object[]} [attributes.skippedAssessments] The array of texts, show which assessments should be skipped (those assessments will have good result).\n * @param {Object} [attributes.data] Given data.\n * @param {Object} [attributes.customData] Custom data.\n * @param {Object} [attributes.shopSettings] Shop's settings.\n * @param {string} [attributes.textTitle] The title of the text.\n * @param {string} [attributes.writingDirection=LTR] The writing direction of the paper. Defaults to left to right (LTR).\n * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.\n */\n constructor(text, attributes) {\n this._text = cleanHTML(text || '');\n\n this._tree = null;\n\n attributes = attributes || {};\n defaults(attributes, defaultAttributes);\n\n if (attributes.locale === '') {\n attributes.locale = defaultAttributes.locale;\n }\n\n if (attributes.hasOwnProperty('url')) {\n attributes.slug = attributes.url || attributes.slug;\n }\n\n const onlyLetters = attributes.keyword.replace(\n /[‘’“”\"'.?!:;,¿¡«»&*@#±^%|~`[\\](){}⟨⟩<>/\\\\–\\-\\u2014\\u00d7\\u002b\\s]/g,\n ''\n );\n\n if (isEmpty(onlyLetters)) {\n attributes.keyword = defaultAttributes.keyword;\n }\n\n this._attributes = attributes;\n }\n\n /**\n * Checks whether a keyword is available.\n * @returns {boolean} Returns true if the Paper has a keyword.\n */\n hasKeyword() {\n return this._attributes.keyword !== '';\n }\n\n /**\n * Returns the associated keyword or an empty string if no keyword is available.\n * @returns {string} Returns Keyword\n */\n getKeyword() {\n return this._attributes.keyword;\n }\n\n /**\n *\n * @returns {*|{keyword?: string, synonyms?: string, description?: string, title?: string, titleCount?: (number|null), h1Count?: (number|null), titleWidth?: number, slug?: string, locale?: string, permalink?: string, date?: string, wpBlocks?: Object[], customData?: Object, textTitle?: string, writingDirection?: string, isFrontPage?: boolean}|{}|{}}\n */\n getAttributes() {\n return this._attributes;\n }\n\n /**\n * Checks whether synonyms are available.\n * @returns {boolean} Returns true if the Paper has synonyms.\n */\n hasSynonyms() {\n return this._attributes.synonyms !== '';\n }\n\n /**\n * Returns the associated synonyms or an empty string if no synonyms is available.\n * @returns {string} Returns synonyms.\n */\n getSynonyms() {\n return this._attributes.synonyms;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getRelatedKeywords() {\n const data = this.getData();\n return (data?.related_keywords || []).map(keyword => keyword.text);\n }\n\n /**\n * Checks whether the h1 count value is available.\n * @returns {boolean} Returns true if the paper has a h1 count value.\n */\n hasH1Count() {\n return !isNull(this._attributes.h1Count);\n }\n\n /**\n * Returns the h1 tag count value.\n * @returns {number | null}\n */\n getH1Count() {\n return this._attributes.h1Count;\n }\n\n /**\n * Checks whether the title count value is available.\n * @returns {boolean} Returns true if the paper has a title count.\n */\n hasTitleCount() {\n return !isNull(this._attributes.titleCount);\n }\n\n /**\n * Returns the title count value.\n * @returns {number | null}\n */\n getTitleCount() {\n return this._attributes.titleCount;\n }\n\n /**\n * Checks whether the text is available.\n * @returns {boolean} Returns true if the paper has a text.\n */\n hasText() {\n return this._text !== '';\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getText() {\n return this._text;\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getDomain() {\n return this._attributes.domain;\n }\n\n /**\n * Sets the tree.\n *\n * @param {Node} tree The tree to set.\n *\n * @returns {void}\n */\n setTree(tree) {\n this._tree = tree;\n }\n\n /**\n * Returns the tree.\n *\n * @returns {Node} The tree.\n */\n getTree() {\n return this._tree;\n }\n\n /**\n * Checks whether a description is available.\n * @returns {boolean} Returns true if the paper has a description.\n */\n hasDescription() {\n return this._attributes.description !== '';\n }\n\n /**\n * Returns the description or an empty string if no description is available.\n * @returns {string} Returns the description.\n */\n getDescription() {\n return this._attributes.description;\n }\n\n /**\n * Checks whether an SEO title is available\n * @returns {boolean} Returns true if the Paper has an SEO title.\n */\n hasTitle() {\n return this._attributes.title !== '';\n }\n\n /**\n * Returns the SEO title, or an empty string if no title is available.\n * @returns {string} Returns the SEO title.\n */\n getTitle() {\n return this._attributes.title;\n }\n\n /**\n * Checks whether an SEO title width in pixels is available.\n * @returns {boolean} Returns true if the Paper's SEO title is wider than 0 pixels.\n */\n hasTitleWidth() {\n return this._attributes.titleWidth !== 0;\n }\n\n /**\n * Gets the SEO title width in pixels, or an empty string of no title width in pixels is available.\n * @returns {number} Returns the SEO title width in pixels.\n */\n getTitleWidth() {\n return this._attributes.titleWidth;\n }\n\n /**\n * Checks whether a slug is available.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasSlug() {\n return this._attributes.slug !== '';\n }\n\n /**\n * Checks whether a shop settings is available.\n * @returns {boolean} Returns true if the Paper has a shop settings.\n */\n hasShopSettings() {\n return !isEmpty(this._attributes?.shopSettings || {});\n }\n\n /**\n * Gets the paper's slug, or an empty string if no slug is available.\n * @returns {string} Returns the slug.\n */\n getSlug() {\n return this._attributes.slug;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasProductSchema() {\n return this._attributes?.hasProductSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasFAQsSchema() {\n return this._attributes?.hasFAQsSchema || false;\n }\n\n /**\n *\n * @returns {boolean}\n */\n hasFAQs() {\n return 'faqs' in this.getData() && this.getFAQs().length > 0;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasArticleSchema() {\n return this._attributes?.hasArticleSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasData() {\n const data = this._attributes?.data;\n return isObject(data) && !isEmpty(data);\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasRelatedKeywords() {\n const relatedKeywords = this._attributes?.data?.related_keywords || [];\n return Array.isArray(relatedKeywords) && relatedKeywords.length > 0;\n }\n\n /**\n *\n * @returns {Object|{}}\n */\n getData() {\n return this._attributes?.data || {};\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getIgnoredAssessments() {\n return this._attributes?.ignoredAssessments || [];\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getPageType() {\n return this._attributes?.pageType || '';\n }\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getSkippedAssessments() {\n return this._attributes?.skippedAssessments || [];\n }\n\n /**\n *\n * @returns {*|{}}\n */\n getShopSettings() {\n return this._attributes?.shopSettings || {};\n }\n\n /**\n * Checks if currently edited page is a front page.\n * @returns {boolean} Returns true if the current page is a front page.\n */\n isFrontPage() {\n return this._attributes.isFrontPage;\n }\n\n /**\n * Checks whether an url is available\n * @deprecated Since version 1.19.1. Use hasSlug instead.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasUrl() {\n console.warn('This function is deprecated, use hasSlug instead');\n return this.hasSlug();\n }\n\n /**\n * Returns the url, or an empty string if no url is available.\n * @deprecated Since version 1.19.1. Use getSlug instead.\n * @returns {string} Returns the url\n */\n getUrl() {\n console.warn('This function is deprecated, use getSlug instead');\n return this.getSlug();\n }\n\n /**\n * Checks whether a locale is available.\n * @returns {boolean} Returns true if the paper has a locale.\n */\n hasLocale() {\n return this._attributes.locale !== '';\n }\n\n /**\n * Returns the locale or an empty string if no locale is available\n * @returns {string} Returns the locale.\n */\n getLocale() {\n return this._attributes.locale;\n }\n\n /**\n * Gets the information of the writing direction of the paper.\n * It returns \"LTR\" (left to right) if this attribute is not provided.\n *\n * @returns {string} Returns the information of the writing direction of the paper.\n */\n getWritingDirection() {\n return this._attributes.writingDirection;\n }\n\n /**\n * Checks whether a permalink is available.\n * @returns {boolean} Returns true if the Paper has a permalink.\n */\n hasPermalink() {\n return this._attributes.permalink !== '';\n }\n\n /**\n * Returns the permalink, or an empty string if no permalink is available.\n * @returns {string} Returns the permalink.\n */\n getPermalink() {\n return this._attributes.permalink;\n }\n\n /**\n * Checks whether a date is available.\n * @returns {boolean} Returns true if the Paper has a date.\n */\n hasDate() {\n return this._attributes.date !== '';\n }\n\n /**\n * Returns the date, or an empty string if no date is available.\n * @returns {string} Returns the date.\n */\n getDate() {\n return this._attributes.date;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getFAQs() {\n return this.getData()?.faqs || {};\n }\n\n\n /**\n * Checks whether custom data is available.\n * @returns {boolean} Returns true if the Paper has custom data.\n */\n hasCustomData() {\n return !isEmpty(this._attributes.customData);\n }\n\n /**\n * Returns the custom data, or an empty object if no data is available.\n * @returns {Object} Returns the custom data.\n */\n getCustomData() {\n return this._attributes.customData;\n }\n\n /**\n * Checks whether a text title is available.\n * @returns {boolean} Returns true if the Paper has a text title.\n */\n hasTextTitle() {\n return this._attributes.textTitle !== '' && !isNil(this._attributes.textTitle);\n }\n\n /**\n * Returns the text title, or an empty string if no data is available.\n * @returns {string} Returns the text title.\n */\n getTextTitle() {\n return this._attributes.textTitle;\n }\n\n /**\n * Serializes the Paper instance to an object.\n *\n * @returns {Object} The serialized Paper.\n */\n serialize() {\n return {\n _parseClass: 'Paper',\n text: this._text,\n ...this._attributes\n };\n }\n\n /**\n * Checks whether the given paper has the same properties as this instance.\n *\n * @param {Paper} paper The paper to compare to.\n *\n * @returns {boolean} Whether the given paper is identical or not.\n */\n equals(paper) {\n return this._text === paper.getText() && isEqual(this._attributes, paper._attributes);\n }\n\n /**\n * Parses the object to a Paper.\n *\n * @param {Object|Paper} serialized The serialized object or Paper instance.\n *\n * @returns {Paper} The parsed Paper.\n */\n static parse(serialized) {\n // For ease of use, check if it is not already a Paper instance.\n if (serialized instanceof Paper) {\n return serialized;\n }\n\n // _parseClass is taken here, so it doesn't end up in the attributes.\n // eslint-disable-next-line no-unused-vars\n const {text, _parseClass, ...attributes} = serialized;\n\n return new Paper(text, attributes);\n }\n}\n"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAA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D,WAAW,CAACf,SAAS;EACnC;;EAEA;AACF;AACA;AACA;AACA;EACE+E,SAASA,CAAA,EAAG;IACV,OAAO;MACLC,WAAW,EAAE,OAAO;MACpBzE,IAAI,EAAE,IAAI,CAACE,KAAK;MAChB,GAAG,IAAI,CAACM;IACV,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEkE,MAAMA,CAACC,KAAK,EAAE;IACZ,OAAO,IAAI,CAACzE,KAAK,KAAKyE,KAAK,CAACnD,OAAO,CAAC,CAAC,IAAInD,OAAO,CAAC,IAAI,CAACmC,WAAW,EAAEmE,KAAK,CAACnE,WAAW,CAAC;EACvF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,OAAOoE,KAAKA,CAACC,UAAU,EAAE;IACvB;IACA,IAAIA,UAAU,YAAY/E,KAAK,EAAE;MAC/B,OAAO+E,UAAU;IACnB;;IAEA;IACA;IACA,MAAM;MAAC7E,IAAI;MAAEyE,WAAW;MAAE,GAAGxE;IAAU,CAAC,GAAG4E,UAAU;IAErD,OAAO,IAAI/E,KAAK,CAACE,IAAI,EAAEC,UAAU,CAAC;EACpC;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Paper.js","names":["defaults","isEmpty","isEqual","isNil","isNull","isObject","cleanHTML","transformRelatedKeyword","defaultAttributes","keyword","synonyms","description","title","titleWidth","titleCount","h1Count","slug","domain","locale","permalink","date","customData","textTitle","writingDirection","wpBlocks","isFrontPage","pageType","Paper","constructor","text","attributes","_text","_tree","hasOwnProperty","url","onlyLetters","replace","_attributes","hasKeyword","getKeyword","getAttributes","hasSynonyms","getSynonyms","getRelatedKeywords","data","getData","related_keywords","map","hasH1Count","getH1Count","hasTitleCount","getTitleCount","hasText","getText","getDomain","setTree","tree","getTree","hasDescription","body_html","descriptionHtml","getDescription","hasTitle","getTitle","hasTitleWidth","getTitleWidth","hasSlug","hasShopSettings","shopSettings","getSlug","hasProductSchema","hasFAQsSchema","hasFAQs","getFAQs","length","hasArticleSchema","hasData","hasRelatedKeywords","relatedKeywords","Array","isArray","getIgnoredAssessments","ignoredAssessments","getPageType","getSkippedAssessments","skippedAssessments","getShopSettings","hasUrl","console","warn","getUrl","hasLocale","getLocale","getWritingDirection","hasPermalink","getPermalink","hasDate","getDate","faqs","hasCustomData","getCustomData","hasTextTitle","getTextTitle","serialize","_parseClass","equals","paper","parse","serialized"],"sources":["../../../src/values/Paper.js"],"sourcesContent":["import {defaults, isEmpty, isEqual, isNil, isNull, isObject} from 'lodash';\nimport {cleanHTML} from '@axyseo/helpers';\nimport {transformRelatedKeyword} from '@axyseo/languageProcessing/researches/checkRelatedKeywords';\n\n/**\n * Default attributes to be used by the Paper if they are left undefined.\n * @type {{keyword: string, synonyms: string, description: string, title: string, titleWidth: number,\n * \t\t slug: string, locale: string, permalink: string, date: string, customData: object, textTitle: string,\n * \t\t writingDirection: \"LTR\", isFrontPage: boolean }}\n */\nconst defaultAttributes = {\n keyword: '',\n synonyms: '',\n description: '',\n title: '',\n titleWidth: 0,\n titleCount: null,\n h1Count: null,\n slug: '',\n domain: '',\n locale: 'en_US',\n permalink: '',\n date: '',\n customData: {},\n textTitle: '',\n writingDirection: 'LTR',\n wpBlocks: [],\n isFrontPage: false,\n pageType: '',\n};\n\n/**\n * Represents an object where the analysis data is stored.\n */\nexport default class Paper {\n /**\n * Constructs the Paper object and sets its attributes.\n *\n * @param {string} text The text to use in the analysis.\n * @param {object} [attributes] The object containing all attributes.\n * @param {string} [attributes.keyword] The main keyword or keyphrase of the text.\n * @param {string} [attributes.synonyms] The synonyms of the main keyword or keyphrase. It should be separated by commas if multiple synonyms are added.\n * @param {string} [attributes.description] The SEO meta description.\n * @param {string} [attributes.title] The SEO title.\n * @param {string} [attributes.domain] The shop domain.\n * @param {number|null} [attributes.titleCount=null] The title tag count value.\n * @param {number|null} [attributes.h1Count=null] The h1 tag count value.\n * @param {number} [attributes.titleWidth=0] The width of the title in pixels.\n * @param {string} [attributes.slug] The slug.\n * @param {string} [attributes.locale=en_US] The locale.\n * @param {string} [attributes.permalink] The full URL for any given post, page, or other pieces of content on a site.\n * @param {string} [attributes.date] The date.\n * @param {Object[]} [attributes.wpBlocks] The array of texts, encoded in WordPress block editor blocks.\n * @param {Object[]} [attributes.ignoredAssessments] The array of texts, show which assessments should be ignored.\n * @param {Object[]} [attributes.skippedAssessments] The array of texts, show which assessments should be skipped (those assessments will have good result).\n * @param {Object} [attributes.data] Given data.\n * @param {Object} [attributes.customData] Custom data.\n * @param {Object} [attributes.shopSettings] Shop's settings.\n * @param {string} [attributes.textTitle] The title of the text.\n * @param {string} [attributes.writingDirection=LTR] The writing direction of the paper. Defaults to left to right (LTR).\n * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.\n */\n constructor(text, attributes) {\n this._text = cleanHTML(text || '');\n\n this._tree = null;\n\n attributes = attributes || {};\n defaults(attributes, defaultAttributes);\n\n if (attributes.locale === '') {\n attributes.locale = defaultAttributes.locale;\n }\n\n if (attributes.hasOwnProperty('url')) {\n attributes.slug = attributes.url || attributes.slug;\n }\n\n const onlyLetters = attributes.keyword.replace(\n /[‘’“”\"'.?!:;,¿¡«»&*@#±^%|~`[\\](){}⟨⟩<>/\\\\–\\-\\u2014\\u00d7\\u002b\\s]/g,\n ''\n );\n\n if (isEmpty(onlyLetters)) {\n attributes.keyword = defaultAttributes.keyword;\n }\n\n this._attributes = attributes;\n }\n\n /**\n * Checks whether a keyword is available.\n * @returns {boolean} Returns true if the Paper has a keyword.\n */\n hasKeyword() {\n return this._attributes.keyword !== '';\n }\n\n /**\n * Returns the associated keyword or an empty string if no keyword is available.\n * @returns {string} Returns Keyword\n */\n getKeyword() {\n return this._attributes.keyword;\n }\n\n /**\n *\n * @returns {*|{keyword?: string, synonyms?: string, description?: string, title?: string, titleCount?: (number|null), h1Count?: (number|null), titleWidth?: number, slug?: string, locale?: string, permalink?: string, date?: string, wpBlocks?: Object[], customData?: Object, textTitle?: string, writingDirection?: string, isFrontPage?: boolean}|{}|{}}\n */\n getAttributes() {\n return this._attributes;\n }\n\n /**\n * Checks whether synonyms are available.\n * @returns {boolean} Returns true if the Paper has synonyms.\n */\n hasSynonyms() {\n return this._attributes.synonyms !== '';\n }\n\n /**\n * Returns the associated synonyms or an empty string if no synonyms is available.\n * @returns {string} Returns synonyms.\n */\n getSynonyms() {\n return this._attributes.synonyms;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getRelatedKeywords() {\n const data = this.getData();\n return (data?.related_keywords || []).map(keyword => keyword.text);\n }\n\n /**\n * Checks whether the h1 count value is available.\n * @returns {boolean} Returns true if the paper has a h1 count value.\n */\n hasH1Count() {\n return !isNull(this._attributes.h1Count);\n }\n\n /**\n * Returns the h1 tag count value.\n * @returns {number | null}\n */\n getH1Count() {\n return this._attributes.h1Count;\n }\n\n /**\n * Checks whether the title count value is available.\n * @returns {boolean} Returns true if the paper has a title count.\n */\n hasTitleCount() {\n return !isNull(this._attributes.titleCount);\n }\n\n /**\n * Returns the title count value.\n * @returns {number | null}\n */\n getTitleCount() {\n return this._attributes.titleCount;\n }\n\n /**\n * Checks whether the text is available.\n * @returns {boolean} Returns true if the paper has a text.\n */\n hasText() {\n return this._text !== '';\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getText() {\n return this._text;\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getDomain() {\n return this._attributes.domain;\n }\n\n /**\n * Sets the tree.\n *\n * @param {Node} tree The tree to set.\n *\n * @returns {void}\n */\n setTree(tree) {\n this._tree = tree;\n }\n\n /**\n * Returns the tree.\n *\n * @returns {Node} The tree.\n */\n getTree() {\n return this._tree;\n }\n\n /**\n * Checks whether a description is available.\n * @returns {boolean} Returns true if the paper has a description.\n */\n hasDescription() {\n return this._attributes?.data?.body_html !== '' || this._attributes?.data?.descriptionHtml !== '';\n }\n\n /**\n * Returns the description or an empty string if no description is available.\n * @returns {string} Returns the description.\n */\n getDescription() {\n return this._attributes.description;\n }\n\n /**\n * Checks whether an SEO title is available\n * @returns {boolean} Returns true if the Paper has an SEO title.\n */\n hasTitle() {\n return this._attributes.title !== '';\n }\n\n /**\n * Returns the SEO title, or an empty string if no title is available.\n * @returns {string} Returns the SEO title.\n */\n getTitle() {\n return this._attributes.title;\n }\n\n /**\n * Checks whether an SEO title width in pixels is available.\n * @returns {boolean} Returns true if the Paper's SEO title is wider than 0 pixels.\n */\n hasTitleWidth() {\n return this._attributes.titleWidth !== 0;\n }\n\n /**\n * Gets the SEO title width in pixels, or an empty string of no title width in pixels is available.\n * @returns {number} Returns the SEO title width in pixels.\n */\n getTitleWidth() {\n return this._attributes.titleWidth;\n }\n\n /**\n * Checks whether a slug is available.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasSlug() {\n return this._attributes.slug !== '';\n }\n\n /**\n * Checks whether a shop settings is available.\n * @returns {boolean} Returns true if the Paper has a shop settings.\n */\n hasShopSettings() {\n return !isEmpty(this._attributes?.shopSettings || {});\n }\n\n /**\n * Gets the paper's slug, or an empty string if no slug is available.\n * @returns {string} Returns the slug.\n */\n getSlug() {\n return this._attributes.slug;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasProductSchema() {\n return this._attributes?.hasProductSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasFAQsSchema() {\n return this._attributes?.hasFAQsSchema || false;\n }\n\n /**\n *\n * @returns {boolean}\n */\n hasFAQs() {\n return 'faqs' in this.getData() && this.getFAQs().length > 0;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasArticleSchema() {\n return this._attributes?.hasArticleSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasData() {\n const data = this._attributes?.data;\n return isObject(data) && !isEmpty(data);\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasRelatedKeywords() {\n const relatedKeywords = this._attributes?.data?.related_keywords || [];\n return Array.isArray(relatedKeywords) && relatedKeywords.length > 0;\n }\n\n /**\n *\n * @returns {Object|{}}\n */\n getData() {\n return this._attributes?.data || {};\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getIgnoredAssessments() {\n return this._attributes?.ignoredAssessments || [];\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getPageType() {\n return this._attributes?.pageType || '';\n }\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getSkippedAssessments() {\n return this._attributes?.skippedAssessments || [];\n }\n\n /**\n *\n * @returns {*|{}}\n */\n getShopSettings() {\n return this._attributes?.shopSettings || {};\n }\n\n /**\n * Checks if currently edited page is a front page.\n * @returns {boolean} Returns true if the current page is a front page.\n */\n isFrontPage() {\n return this._attributes.isFrontPage;\n }\n\n /**\n * Checks whether an url is available\n * @deprecated Since version 1.19.1. Use hasSlug instead.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasUrl() {\n console.warn('This function is deprecated, use hasSlug instead');\n return this.hasSlug();\n }\n\n /**\n * Returns the url, or an empty string if no url is available.\n * @deprecated Since version 1.19.1. Use getSlug instead.\n * @returns {string} Returns the url\n */\n getUrl() {\n console.warn('This function is deprecated, use getSlug instead');\n return this.getSlug();\n }\n\n /**\n * Checks whether a locale is available.\n * @returns {boolean} Returns true if the paper has a locale.\n */\n hasLocale() {\n return this._attributes.locale !== '';\n }\n\n /**\n * Returns the locale or an empty string if no locale is available\n * @returns {string} Returns the locale.\n */\n getLocale() {\n return this._attributes.locale;\n }\n\n /**\n * Gets the information of the writing direction of the paper.\n * It returns \"LTR\" (left to right) if this attribute is not provided.\n *\n * @returns {string} Returns the information of the writing direction of the paper.\n */\n getWritingDirection() {\n return this._attributes.writingDirection;\n }\n\n /**\n * Checks whether a permalink is available.\n * @returns {boolean} Returns true if the Paper has a permalink.\n */\n hasPermalink() {\n return this._attributes.permalink !== '';\n }\n\n /**\n * Returns the permalink, or an empty string if no permalink is available.\n * @returns {string} Returns the permalink.\n */\n getPermalink() {\n return this._attributes.permalink;\n }\n\n /**\n * Checks whether a date is available.\n * @returns {boolean} Returns true if the Paper has a date.\n */\n hasDate() {\n return this._attributes.date !== '';\n }\n\n /**\n * Returns the date, or an empty string if no date is available.\n * @returns {string} Returns the date.\n */\n getDate() {\n return this._attributes.date;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getFAQs() {\n return this.getData()?.faqs || {};\n }\n\n\n /**\n * Checks whether custom data is available.\n * @returns {boolean} Returns true if the Paper has custom data.\n */\n hasCustomData() {\n return !isEmpty(this._attributes.customData);\n }\n\n /**\n * Returns the custom data, or an empty object if no data is available.\n * @returns {Object} Returns the custom data.\n */\n getCustomData() {\n return this._attributes.customData;\n }\n\n /**\n * Checks whether a text title is available.\n * @returns {boolean} Returns true if the Paper has a text title.\n */\n hasTextTitle() {\n return this._attributes.textTitle !== '' && !isNil(this._attributes.textTitle);\n }\n\n /**\n * Returns the text title, or an empty string if no data is available.\n * @returns {string} Returns the text title.\n */\n getTextTitle() {\n return this._attributes.textTitle;\n }\n\n /**\n * Serializes the Paper instance to an object.\n *\n * @returns {Object} The serialized Paper.\n */\n serialize() {\n return {\n _parseClass: 'Paper',\n text: this._text,\n ...this._attributes\n };\n }\n\n /**\n * Checks whether the given paper has the same properties as this instance.\n *\n * @param {Paper} paper The paper to compare to.\n *\n * @returns {boolean} Whether the given paper is identical or not.\n */\n equals(paper) {\n return this._text === paper.getText() && isEqual(this._attributes, paper._attributes);\n }\n\n /**\n * Parses the object to a Paper.\n *\n * @param {Object|Paper} serialized The serialized object or Paper instance.\n *\n * @returns {Paper} The parsed Paper.\n */\n static parse(serialized) {\n // For ease of use, check if it is not already a Paper instance.\n if (serialized instanceof Paper) {\n return serialized;\n }\n\n // _parseClass is taken here, so it doesn't end up in the attributes.\n // eslint-disable-next-line no-unused-vars\n const {text, _parseClass, ...attributes} = serialized;\n\n return new Paper(text, attributes);\n }\n}\n"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,EAA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