-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20695 from Yoast/238-move-the-frequency-lists-of-…
…word-complexity-assessment-to-premium-configuration-repo Move the frequency lists of the word complexity assessment out of `yoastseo` package
- Loading branch information
Showing
24 changed files
with
190 additions
and
8,538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
apps/content-analysis/src/utils/registerPremiumAssessments.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { getLanguagesWithWordComplexity } from "yoastseo/src/helpers/getLanguagesWithWordComplexity"; | ||
|
||
// Configs for the supported languages. | ||
import wordComplexityConfigEnglish from "yoastseo/src/languageProcessing/languages/en/config/wordComplexity"; | ||
import wordComplexityConfigGerman from "yoastseo/src/languageProcessing/languages/de/config/wordComplexity"; | ||
import wordComplexityConfigSpanish from "yoastseo/src/languageProcessing/languages/es/config/wordComplexity"; | ||
import wordComplexityConfigFrench from "yoastseo/src/languageProcessing/languages/fr/config/wordComplexity"; | ||
|
||
// Helpers for the supported languages. | ||
import wordComplexityHelperEnglish from "yoastseo/src/languageProcessing/languages/en/helpers/checkIfWordIsComplex"; | ||
import wordComplexityHelperGerman from "yoastseo/src/languageProcessing/languages/de/helpers/checkIfWordIsComplex"; | ||
import wordComplexityHelperSpanish from "yoastseo/src/languageProcessing/languages/es/helpers/checkIfWordIsComplex"; | ||
import wordComplexityHelperFrench from "yoastseo/src/languageProcessing/languages/fr/helpers/checkIfWordIsComplex"; | ||
// Research. | ||
import wordComplexity from "yoastseo/src/languageProcessing/researches/wordComplexity"; | ||
import keyPhraseDistribution from "yoastseo/src/languageProcessing/researches/keyphraseDistribution"; | ||
|
||
// Assessment. | ||
import WordComplexityAssessment from "yoastseo/src/scoring/assessments/readability/WordComplexityAssessment"; | ||
import KeyphraseDistributionAssessment from "yoastseo/src/scoring/assessments/seo/KeyphraseDistributionAssessment"; | ||
|
||
const helpers = { | ||
de: wordComplexityHelperGerman, | ||
en: wordComplexityHelperEnglish, | ||
es: wordComplexityHelperSpanish, | ||
fr: wordComplexityHelperFrench, | ||
}; | ||
|
||
const configs = { | ||
de: wordComplexityConfigGerman, | ||
en: wordComplexityConfigEnglish, | ||
es: wordComplexityConfigSpanish, | ||
fr: wordComplexityConfigFrench, | ||
}; | ||
|
||
const pluginName = "YoastSEOPremium"; | ||
|
||
export default function( worker, language ) { | ||
if ( getLanguagesWithWordComplexity().includes( language ) ) { | ||
// Get the word complexity config for the specific language. | ||
const wordComplexityConfig = configs[ language ]; | ||
// Get the word complexity helper for the specific language. | ||
const wordComplexityHelper = helpers[ language ]; | ||
// Initialize the assessment for regular content. | ||
const wordComplexityAssessment = new WordComplexityAssessment(); | ||
// Initialize the assessment for cornerstone content. | ||
const wordComplexityAssessmentCornerstone = new WordComplexityAssessment( { | ||
scores: { | ||
acceptableAmount: 3, | ||
}, | ||
} ); | ||
|
||
// Register the word complexity config. | ||
worker.registerResearcherConfig( "wordComplexity", wordComplexityConfig ); | ||
|
||
// Register the word complexity helper. | ||
worker.registerHelper( "checkIfWordIsComplex", wordComplexityHelper ); | ||
|
||
// Register the word complexity research. | ||
worker.registerResearch( "wordComplexity", wordComplexity ); | ||
|
||
// Register the word complexity assessment for regular content. | ||
worker.registerAssessment( "wordComplexity", wordComplexityAssessment, pluginName, "readability" ); | ||
|
||
// Register the word complexity assessment for cornerstone content. | ||
worker.registerAssessment( "wordComplexity", wordComplexityAssessmentCornerstone, pluginName, "cornerstoneReadability" ); | ||
} | ||
const keyphraseDistributionAssessment = new KeyphraseDistributionAssessment(); | ||
worker.registerResearch( "keyphraseDistribution", keyPhraseDistribution ); | ||
worker.registerAssessment( "keyphraseDistributionAssessment", keyphraseDistributionAssessment, pluginName, "seo" ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 10 additions & 8 deletions
18
packages/yoastseo/spec/languageProcessing/languages/de/helpers/checkIfWordIsComplexSpec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,37 @@ | ||
import checkIfWordIsComplex from "../../../../../src/languageProcessing/languages/de/helpers/checkIfWordIsComplex"; | ||
import wordComplexityConfig from "../../../../../src/languageProcessing/languages/de/config/wordComplexity"; | ||
import getMorphologyData from "../../../../specHelpers/getMorphologyData"; | ||
const premiumData = getMorphologyData( "de" ).de; | ||
|
||
describe( "a test checking if the word is complex in German", function() { | ||
it( "returns singular word form as non-complex if it is found in the list", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "präsident" ) ).toEqual( false ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "präsident", premiumData ) ).toEqual( false ); | ||
} ); | ||
|
||
it( "returns plural word form as non-complex if its singular form is found in the list", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "Verstärkungen" ) ).toEqual( false ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "Verstärkungen", premiumData ) ).toEqual( false ); | ||
} ); | ||
|
||
it( "returns plural word form as non-complex if its singular form is found in the list", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "Gouverneure" ) ).toEqual( false ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "Gouverneure", premiumData ) ).toEqual( false ); | ||
} ); | ||
it( "returns word as non-complex if it is found in the function words list", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "verschiedenes" ) ).toEqual( false ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "verschiedenes", premiumData ) ).toEqual( false ); | ||
} ); | ||
|
||
it( "returns plural word as complex if it (and its singular form) are not in the list", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "optimierungen" ) ).toEqual( true ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "optimierungen", premiumData ) ).toEqual( true ); | ||
} ); | ||
|
||
it( "returns word longer than 10 characters as complex if it's not in the list", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "architektonisch" ) ).toEqual( true ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "architektonisch", premiumData ) ).toEqual( true ); | ||
} ); | ||
|
||
it( "returns plural word as non complex if the word is less than 10 characters", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "boxen" ) ).toEqual( false ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "boxen", premiumData ) ).toEqual( false ); | ||
} ); | ||
|
||
it( "recognized contractions when the contraction uses ’ (right single quotation mark) instead of ' (apostrophe)", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "l’histoire" ) ).toEqual( false ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "l’histoire", premiumData ) ).toEqual( false ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 10 additions & 8 deletions
18
packages/yoastseo/spec/languageProcessing/languages/es/helpers/checkIfWordIsComplexSpec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,37 @@ | ||
import checkIfWordIsComplex from "../../../../../src/languageProcessing/languages/es/helpers/checkIfWordIsComplex"; | ||
import wordComplexityConfig from "../../../../../src/languageProcessing/languages/es/config/wordComplexity"; | ||
import getMorphologyData from "../../../../specHelpers/getMorphologyData"; | ||
const premiumData = getMorphologyData( "es" ).es; | ||
|
||
describe( "a test checking if the word is complex in Spanish", function() { | ||
it( "returns singular word form as non-complex if it is found in the list", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "original" ) ).toEqual( false ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "original", premiumData ) ).toEqual( false ); | ||
} ); | ||
|
||
// eslint-disable-next-line max-len | ||
it( "returns plural word form as non-complex if its singular form is found in the list when the singular word form ends with a consonant", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "originales" ) ).toEqual( false ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "originales", premiumData ) ).toEqual( false ); | ||
} ); | ||
|
||
// eslint-disable-next-line max-len | ||
it( "returns plural word form as non-complex if its singular form is found in the list when the singular word form ends with a vowel", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "parecidos" ) ).toEqual( false ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "parecidos", premiumData ) ).toEqual( false ); | ||
} ); | ||
|
||
it( "returns word as non-complex if it starts with a capital (even if non capitalized form is complex)", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "Alhambra" ) ).toEqual( false ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "alhambra" ) ).toEqual( true ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "Alhambra", premiumData ) ).toEqual( false ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "alhambra", premiumData ) ).toEqual( true ); | ||
} ); | ||
|
||
it( "returns plural word as complex if it (and its singular form) are not in the list", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "situados" ) ).toEqual( true ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "situados", premiumData ) ).toEqual( true ); | ||
} ); | ||
|
||
it( "returns word longer than 7 characters as complex if it's not in the list", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "contemplada" ) ).toEqual( true ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "contemplada", premiumData ) ).toEqual( true ); | ||
} ); | ||
|
||
it( "returns plural word as non complex if the word is less than 7 characters", function() { | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "cosas" ) ).toEqual( false ); | ||
expect( checkIfWordIsComplex( wordComplexityConfig, "cosas", premiumData ) ).toEqual( false ); | ||
} ); | ||
} ); |
Oops, something went wrong.