axyseo 2.0.0-alpha.0.0.46 → 2.0.0-alpha.0.0.47

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 { getSubheadingContentsTopLevel } from "../helpers/html/getSubheadings";
1
+ import { getSubheadingContents } 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";
@@ -35,15 +35,15 @@ const numberOfSubheadingsReflectingTopic = function (topicForms, subheadings, us
35
35
  * @returns {Object} The result object.
36
36
  */
37
37
  export default function matchKeywordInSubheadings(paper, researcher) {
38
- const functionWords = researcher.getConfig("functionWords");
38
+ const functionWords = researcher.getConfig('functionWords');
39
39
 
40
40
  // A custom helper to match word in text.
41
- const matchWordCustomHelper = researcher.getHelper("matchWordCustomHelper");
41
+ const matchWordCustomHelper = researcher.getHelper('matchWordCustomHelper');
42
42
  let text = paper.getText();
43
43
  text = removeHtmlBlocks(text);
44
44
  text = filterShortcodesFromHTML(text, paper._attributes && paper._attributes.shortcodes);
45
45
  text = stripSomeTags(text);
46
- const topicForms = researcher.getResearch("morphology");
46
+ const topicForms = researcher.getResearch('morphology');
47
47
  const locale = paper.getLocale();
48
48
  const result = {
49
49
  count: 0,
@@ -51,7 +51,7 @@ export default function matchKeywordInSubheadings(paper, researcher) {
51
51
  percentReflectingTopic: 0
52
52
  };
53
53
  const useSynonyms = true;
54
- const subheadings = getSubheadingContentsTopLevel(text);
54
+ const subheadings = getSubheadingContents(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":["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( topicForms, subheadings, useSynonyms, locale, functionWords, matchWordCustomHelper ) {\n\treturn subheadings.filter( subheading => {\n\t\tconst matchedTopicForms = findTopicFormsInString( topicForms, subheading, useSynonyms, locale, matchWordCustomHelper );\n\n\t\tif ( functionWords.length === 0 ) {\n\t\t\treturn matchedTopicForms.percentWordMatches === 100;\n\t\t}\n\t\treturn matchedTopicForms.percentWordMatches > 50;\n\t} ).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\tconst functionWords = researcher.getConfig( \"functionWords\" );\n\n\t// A custom helper to match word in text.\n\tconst matchWordCustomHelper = researcher.getHelper( \"matchWordCustomHelper\" );\n\n\n\tlet text = paper.getText();\n\ttext = removeHtmlBlocks( text );\n\ttext = filterShortcodesFromHTML( text, paper._attributes && paper._attributes.shortcodes );\n\ttext = stripSomeTags( text );\n\tconst topicForms = researcher.getResearch( \"morphology\" );\n\tconst locale = paper.getLocale();\n\tconst result = { count: 0, matches: 0, percentReflectingTopic: 0 };\n\tconst useSynonyms = true;\n\tconst subheadings = getSubheadingContentsTopLevel( text );\n\n\tif ( subheadings.length !== 0 ) {\n\t\tresult.count = subheadings.length;\n\t\tresult.matches = numberOfSubheadingsReflectingTopic( topicForms, subheadings, useSynonyms, locale, functionWords, matchWordCustomHelper );\n\t\tresult.percentReflectingTopic = result.matches / result.count * 100;\n\t}\n\n\treturn result;\n}\n"],"mappings":"AAAA,SAASA,6BAA6B;AACtC,OAAOC,aAAa;AACpB,SAASC,sBAAsB;AAC/B,OAAOC,gBAAgB;AACvB,SAASC,wBAAwB;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kCAAkC,GAAG,SAAAA,CAAUC,UAAU,EAAEC,WAAW,EAAEC,WAAW,EAAEC,MAAM,EAAEC,aAAa,EAAEC,qBAAqB,EAAG;EACzI,OAAOJ,WAAW,CAACK,MAAM,CAAEC,UAAU,IAAI;IACxC,MAAMC,iBAAiB,GAAGZ,sBAAsB,CAAEI,UAAU,EAAEO,UAAU,EAAEL,WAAW,EAAEC,MAAM,EAAEE,qBAAsB,CAAC;IAEtH,IAAKD,aAAa,CAACK,MAAM,KAAK,CAAC,EAAG;MACjC,OAAOD,iBAAiB,CAACE,kBAAkB,KAAK,GAAG;IACpD;IACA,OAAOF,iBAAiB,CAACE,kBAAkB,GAAG,EAAE;EACjD,CAAE,CAAC,CAACD,MAAM;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASE,yBAAyBA,CAAEC,KAAK,EAAEC,UAAU,EAAG;EACtE,MAAMT,aAAa,GAAGS,UAAU,CAACC,SAAS,CAAE,eAAgB,CAAC;;EAE7D;EACA,MAAMT,qBAAqB,GAAGQ,UAAU,CAACE,SAAS,CAAE,uBAAwB,CAAC;EAG7E,IAAIC,IAAI,GAAGJ,KAAK,CAACK,OAAO,CAAC,CAAC;EAC1BD,IAAI,GAAGnB,gBAAgB,CAAEmB,IAAK,CAAC;EAC/BA,IAAI,GAAGlB,wBAAwB,CAAEkB,IAAI,EAAEJ,KAAK,CAACM,WAAW,IAAIN,KAAK,CAACM,WAAW,CAACC,UAAW,CAAC;EAC1FH,IAAI,GAAGrB,aAAa,CAAEqB,IAAK,CAAC;EAC5B,MAAMhB,UAAU,GAAGa,UAAU,CAACO,WAAW,CAAE,YAAa,CAAC;EACzD,MAAMjB,MAAM,GAAGS,KAAK,CAACS,SAAS,CAAC,CAAC;EAChC,MAAMC,MAAM,GAAG;IAAEC,KAAK,EAAE,CAAC;IAAEC,OAAO,EAAE,CAAC;IAAEC,sBAAsB,EAAE;EAAE,CAAC;EAClE,MAAMvB,WAAW,GAAG,IAAI;EACxB,MAAMD,WAAW,GAAGP,6BAA6B,CAAEsB,IAAK,CAAC;EAEzD,IAAKf,WAAW,CAACQ,MAAM,KAAK,CAAC,EAAG;IAC/Ba,MAAM,CAACC,KAAK,GAAGtB,WAAW,CAACQ,MAAM;IACjCa,MAAM,CAACE,OAAO,GAAGzB,kCAAkC,CAAEC,UAAU,EAAEC,WAAW,EAAEC,WAAW,EAAEC,MAAM,EAAEC,aAAa,EAAEC,qBAAsB,CAAC;IACzIiB,MAAM,CAACG,sBAAsB,GAAGH,MAAM,CAACE,OAAO,GAAGF,MAAM,CAACC,KAAK,GAAG,GAAG;EACpE;EAEA,OAAOD,MAAM;AACd","ignoreList":[]}
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,wBAAwB;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kCAAkC,GAAG,SAAAA,CACzCC,UAAU,EACVC,WAAW,EACXC,WAAW,EACXC,MAAM,EACNC,aAAa,EACbC,qBAAqB,EACrB;EACA,OAAOJ,WAAW,CAACK,MAAM,CAACC,UAAU,IAAI;IACtC,MAAMC,iBAAiB,GAAGZ,sBAAsB,CAC9CI,UAAU,EACVO,UAAU,EACVL,WAAW,EACXC,MAAM,EACNE,qBACF,CAAC;IAED,IAAID,aAAa,CAACK,MAAM,KAAK,CAAC,EAAE;MAC9B,OAAOD,iBAAiB,CAACE,kBAAkB,KAAK,GAAG;IACrD;IACA,OAAOF,iBAAiB,CAACE,kBAAkB,GAAG,EAAE;EAClD,CAAC,CAAC,CAACD,MAAM;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASE,yBAAyBA,CAACC,KAAK,EAAEC,UAAU,EAAE;EACnE,MAAMT,aAAa,GAAGS,UAAU,CAACC,SAAS,CAAC,eAAe,CAAC;;EAE3D;EACA,MAAMT,qBAAqB,GAAGQ,UAAU,CAACE,SAAS,CAAC,uBAAuB,CAAC;EAE3E,IAAIC,IAAI,GAAGJ,KAAK,CAACK,OAAO,CAAC,CAAC;EAC1BD,IAAI,GAAGnB,gBAAgB,CAACmB,IAAI,CAAC;EAC7BA,IAAI,GAAGlB,wBAAwB,CAACkB,IAAI,EAAEJ,KAAK,CAACM,WAAW,IAAIN,KAAK,CAACM,WAAW,CAACC,UAAU,CAAC;EACxFH,IAAI,GAAGrB,aAAa,CAACqB,IAAI,CAAC;EAC1B,MAAMhB,UAAU,GAAGa,UAAU,CAACO,WAAW,CAAC,YAAY,CAAC;EACvD,MAAMjB,MAAM,GAAGS,KAAK,CAACS,SAAS,CAAC,CAAC;EAChC,MAAMC,MAAM,GAAG;IAACC,KAAK,EAAE,CAAC;IAAEC,OAAO,EAAE,CAAC;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":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axyseo",
3
- "version": "2.0.0-alpha.0.0.46",
3
+ "version": "2.0.0-alpha.0.0.47",
4
4
  "main": "build/index.js",
5
5
  "scripts": {
6
6
  "prepublishOnly": "npm run build && npm version prerelease --preid=alpha",