axyseo 2.0.0-alpha.0.0.48 → 2.0.0-alpha.0.0.49

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.
@@ -1,4 +1,4 @@
1
- import { getSubheadingContents } from "../helpers/html/getSubheadings";
1
+ import { getSubheadingContentsTopLevel } from "../helpers/html/getSubheadings";
2
2
  import stripSomeTags from "../helpers/sanitize/stripNonTextTags";
3
3
  import { findTopicFormsInString } from "../helpers/match/findKeywordFormsInString";
4
4
  import removeHtmlBlocks from "../helpers/html/htmlParser";
@@ -51,7 +51,7 @@ export default function matchKeywordInSubheadings(paper, researcher) {
51
51
  percentReflectingTopic: 0
52
52
  };
53
53
  const useSynonyms = true;
54
- const subheadings = getSubheadingContents(text);
54
+ const subheadings = getSubheadingContentsTopLevel(text);
55
55
  if (subheadings.length !== 0) {
56
56
  result.count = subheadings.length;
57
57
  result.matches = numberOfSubheadingsReflectingTopic(topicForms, subheadings, useSynonyms, locale, functionWords, matchWordCustomHelper);
@@ -1 +1 @@
1
- {"version":3,"file":"matchKeywordInSubheadings.js","names":["getSubheadingContents","stripSomeTags","findTopicFormsInString","removeHtmlBlocks","filterShortcodesFromHTML","numberOfSubheadingsReflectingTopic","topicForms","subheadings","useSynonyms","locale","functionWords","matchWordCustomHelper","filter","subheading","matchedTopicForms","length","percentWordMatches","matchKeywordInSubheadings","paper","researcher","getConfig","getHelper","text","getText","_attributes","shortcodes","getResearch","getLocale","result","count","matches","percentReflectingTopic"],"sources":["../../../src/languageProcessing/researches/matchKeywordInSubheadings.js"],"sourcesContent":["import {getSubheadingContents} from '../helpers/html/getSubheadings';\nimport stripSomeTags from '../helpers/sanitize/stripNonTextTags';\nimport {findTopicFormsInString} from '../helpers/match/findKeywordFormsInString';\nimport removeHtmlBlocks from '../helpers/html/htmlParser';\nimport {filterShortcodesFromHTML} from '../helpers';\n\n/**\n * Computes the amount of subheadings reflecting the topic.\n *\n * @param {Object} topicForms The main key phrase and its synonyms to check.\n * @param {string[]} subheadings The subheadings to check.\n * @param {boolean} useSynonyms Whether to match synonyms or only main keyphrase.\n * @param {string} locale The current locale.\n * @param {Array} functionWords\tThe function words list.\n * @param {function} matchWordCustomHelper The language-specific helper function to match word in text.\n *\n * @returns {number} The amount of subheadings reflecting the topic.\n */\nconst numberOfSubheadingsReflectingTopic = function(\n topicForms,\n subheadings,\n useSynonyms,\n locale,\n functionWords,\n matchWordCustomHelper\n) {\n return subheadings.filter(subheading => {\n const matchedTopicForms = findTopicFormsInString(\n topicForms,\n subheading,\n useSynonyms,\n locale,\n matchWordCustomHelper\n );\n\n if (functionWords.length === 0) {\n return matchedTopicForms.percentWordMatches === 100;\n }\n return matchedTopicForms.percentWordMatches > 50;\n }).length;\n};\n\n/**\n * Checks if there are any h2 or h3 subheadings in the text and if they have the keyphrase or synonyms in them.\n *\n * @param {Object} paper The paper object containing the text and keyword.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {Object} The result object.\n */\nexport default function matchKeywordInSubheadings(paper, researcher) {\n const functionWords = researcher.getConfig('functionWords');\n\n // A custom helper to match word in text.\n const matchWordCustomHelper = researcher.getHelper('matchWordCustomHelper');\n\n let text = paper.getText();\n text = removeHtmlBlocks(text);\n text = filterShortcodesFromHTML(text, paper._attributes && paper._attributes.shortcodes);\n text = stripSomeTags(text);\n const topicForms = researcher.getResearch('morphology');\n const locale = paper.getLocale();\n const result = {count: 0, matches: 0, percentReflectingTopic: 0};\n const useSynonyms = true;\n const subheadings = getSubheadingContents(text);\n\n if (subheadings.length !== 0) {\n result.count = subheadings.length;\n result.matches = numberOfSubheadingsReflectingTopic(\n topicForms,\n subheadings,\n useSynonyms,\n locale,\n functionWords,\n matchWordCustomHelper\n );\n result.percentReflectingTopic = (result.matches / result.count) * 100;\n }\n\n return result;\n}\n"],"mappings":"AAAA,SAAQA,qBAAqB;AAC7B,OAAOC,aAAa;AACpB,SAAQC,sBAAsB;AAC9B,OAAOC,gBAAgB;AACvB,SAAQC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AAC;IAAEC,sBAAsB,EAAE;EAAC,CAAC;EAChE,MAAMvB,WAAW,GAAG,IAAI;EACxB,MAAMD,WAAW,GAAGP,qBAAqB,CAACsB,IAAI,CAAC;EAE/C,IAAIf,WAAW,CAACQ,MAAM,KAAK,CAAC,EAAE;IAC5Ba,MAAM,CAACC,KAAK,GAAGtB,WAAW,CAACQ,MAAM;IACjCa,MAAM,CAACE,OAAO,GAAGzB,kCAAkC,CACjDC,UAAU,EACVC,WAAW,EACXC,WAAW,EACXC,MAAM,EACNC,aAAa,EACbC,qBACF,CAAC;IACDiB,MAAM,CAACG,sBAAsB,GAAIH,MAAM,CAACE,OAAO,GAAGF,MAAM,CAACC,KAAK,GAAI,GAAG;EACvE;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"file":"matchKeywordInSubheadings.js","names":["getSubheadingContentsTopLevel","stripSomeTags","findTopicFormsInString","removeHtmlBlocks","filterShortcodesFromHTML","numberOfSubheadingsReflectingTopic","topicForms","subheadings","useSynonyms","locale","functionWords","matchWordCustomHelper","filter","subheading","matchedTopicForms","length","percentWordMatches","matchKeywordInSubheadings","paper","researcher","getConfig","getHelper","text","getText","_attributes","shortcodes","getResearch","getLocale","result","count","matches","percentReflectingTopic"],"sources":["../../../src/languageProcessing/researches/matchKeywordInSubheadings.js"],"sourcesContent":["import {getSubheadingContentsTopLevel} from '../helpers/html/getSubheadings';\nimport stripSomeTags from '../helpers/sanitize/stripNonTextTags';\nimport {findTopicFormsInString} from '../helpers/match/findKeywordFormsInString';\nimport removeHtmlBlocks from '../helpers/html/htmlParser';\nimport {filterShortcodesFromHTML} from '../helpers';\n\n/**\n * Computes the amount of subheadings reflecting the topic.\n *\n * @param {Object} topicForms The main key phrase and its synonyms to check.\n * @param {string[]} subheadings The subheadings to check.\n * @param {boolean} useSynonyms Whether to match synonyms or only main keyphrase.\n * @param {string} locale The current locale.\n * @param {Array} functionWords\tThe function words list.\n * @param {function} matchWordCustomHelper The language-specific helper function to match word in text.\n *\n * @returns {number} The amount of subheadings reflecting the topic.\n */\nconst numberOfSubheadingsReflectingTopic = function(\n topicForms,\n subheadings,\n useSynonyms,\n locale,\n functionWords,\n matchWordCustomHelper\n) {\n return subheadings.filter(subheading => {\n const matchedTopicForms = findTopicFormsInString(\n topicForms,\n subheading,\n useSynonyms,\n locale,\n matchWordCustomHelper\n );\n\n if (functionWords.length === 0) {\n return matchedTopicForms.percentWordMatches === 100;\n }\n return matchedTopicForms.percentWordMatches > 50;\n }).length;\n};\n\n/**\n * Checks if there are any h2 or h3 subheadings in the text and if they have the keyphrase or synonyms in them.\n *\n * @param {Object} paper The paper object containing the text and keyword.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {Object} The result object.\n */\nexport default function matchKeywordInSubheadings(paper, researcher) {\n const functionWords = researcher.getConfig('functionWords');\n\n // A custom helper to match word in text.\n const matchWordCustomHelper = researcher.getHelper('matchWordCustomHelper');\n\n let text = paper.getText();\n text = removeHtmlBlocks(text);\n text = filterShortcodesFromHTML(text, paper._attributes && paper._attributes.shortcodes);\n text = stripSomeTags(text);\n const topicForms = researcher.getResearch('morphology');\n const locale = paper.getLocale();\n const result = {count: 0, matches: 0, percentReflectingTopic: 0};\n const useSynonyms = true;\n const subheadings = getSubheadingContentsTopLevel(text);\n\n if (subheadings.length !== 0) {\n result.count = subheadings.length;\n result.matches = numberOfSubheadingsReflectingTopic(\n topicForms,\n subheadings,\n useSynonyms,\n locale,\n functionWords,\n matchWordCustomHelper\n );\n result.percentReflectingTopic = (result.matches / result.count) * 100;\n }\n\n return result;\n}\n"],"mappings":"AAAA,SAAQA,6BAA6B;AACrC,OAAOC,aAAa;AACpB,SAAQC,sBAAsB;AAC9B,OAAOC,gBAAgB;AACvB,SAAQC,wBAAwB;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kCAAkC,GAAG,SAAAA,CACzCC,UAAU,EACVC,WAAW,EACXC,WAAW,EACX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CAACQ,MAAM,KAAK,CAAC,EAAE;IAC5Ba,MAAM,CAACC,KAAK,GAAGtB,WAAW,CAACQ,MAAM;IACjCa,MAAM,CAACE,OAAO,GAAGzB,kCAAkC,CACjDC,UAAU,EACVC,WAAW,EACXC,WAAW,EACXC,MAAM,EACNC,aAAa,EACbC,qBACF,CAAC;IACDiB,MAAM,CAACG,sBAAsB,GAAIH,MAAM,CAACE,OAAO,GAAGF,MAAM,CAACC,KAAK,GAAI,GAAG;EACvE;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axyseo",
3
- "version": "2.0.0-alpha.0.0.48",
3
+ "version": "2.0.0-alpha.0.0.49",
4
4
  "main": "build/index.js",
5
5
  "scripts": {
6
6
  "prepublishOnly": "npm run build && npm version prerelease --preid=alpha",