Skip to content
This repository was archived by the owner on Oct 4, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ce4c9c7
indeclinable exceptions and exceptions with full forms
Oct 16, 2019
beacca8
fixes premium-configuration location
Oct 16, 2019
ae65ce1
Merge branch 'feature/Dutch-morphology' of github.com:Yoast/javascrip…
agnieszkaszuba Dec 11, 2019
64b98b7
checks full forms exceptions
Jan 8, 2020
fbde3d7
Merge branch 'feature/Dutch-morphology' of https://github.com/Yoast/j…
Jan 22, 2020
940c353
Improve the checks for full forms exception (Dutch)
FAMarfuaty Jan 27, 2020
f480df8
Merge branch 'feature/Dutch-morphology' of https://github.com/Yoast/j…
FAMarfuaty Jan 28, 2020
8f63163
Restructure the code for checking the full forms exception
FAMarfuaty Feb 3, 2020
8f975ab
Add check for retrieving the stem from exception full forms list
FAMarfuaty Feb 4, 2020
0799b90
Add check for exception list with full forms
FAMarfuaty Feb 4, 2020
175a88b
Restore German generateNounExceptionsForms
FAMarfuaty Feb 5, 2020
e3c51c4
Delete one extra line in the code that should not be there
FAMarfuaty Feb 5, 2020
3d693f2
Merge branch 'feature/Dutch-morphology' of github.com:Yoast/javascrip…
agnieszkaszuba Feb 5, 2020
0bbda9d
Merge branch '371-exceptions-full-forms' of github.com:Yoast/javascri…
agnieszkaszuba Feb 5, 2020
cf85d73
Add a spec for full forms exceptions
agnieszkaszuba Feb 6, 2020
af0d259
Merge branch 'feature/Dutch-morphology' of https://github.com/Yoast/j…
FAMarfuaty Feb 10, 2020
8e82e09
Merge branch '371-exceptions-full-forms' of https://github.com/Yoast/…
FAMarfuaty Feb 10, 2020
a7d7cc3
Update packages/yoastseo/src/morphology/morphoHelpers/checkExceptions…
FAMarfuaty Feb 11, 2020
3bb7d54
Update packages/yoastseo/spec/morphology/morphoHelpers/checkException…
FAMarfuaty Feb 11, 2020
1b32c16
Renaming variables into clearer names and removing unnecessary code
FAMarfuaty Feb 11, 2020
3fc6660
Merge branch 'feature/Dutch-morphology' of https://github.com/Yoast/j…
FAMarfuaty Feb 11, 2020
fa0afa3
Merge branch '371-exceptions-full-forms' of https://github.com/Yoast/…
FAMarfuaty Feb 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,21 @@ describe( "Adds adjective suffixes", () => {
"groeners",
"groenere",
"groeneres",
] );
], );
} );
it( "Adds comparative suffixes to a modified Dutch stem", () => {
expect( addComparativeSuffixes( morphologyDataNL.adjectives, morphologyDataNL.addSuffixes.stemModifications, "zwak" ) ).toEqual( [
"zwakker",
"zwakkers",
"zwakkere",
"zwakkeres",
] );
], );
} );
it( "Adds superlative suffixes to a given Dutch stem", () => {
expect( addSuperlativeSuffixes( morphologyDataNL.adjectives, "groen" ) ).toEqual( [
"groenst",
"groenste",
] );
], );
} );
it( "Adds all adjective suffixes to a given Dutch stem", () => {
expect( addAllAdjectiveSuffixes( morphologyDataNL.adjectives, morphologyDataNL.addSuffixes.stemModifications, "groen" ) ).toEqual( [
Expand All @@ -153,19 +153,7 @@ describe( "Adds adjective suffixes", () => {
"groenste",
"groene",
"groens",
] );
} );
it( "Adds all adjective suffixes to a given Dutch stem", () => {
expect( addAllAdjectiveSuffixes( morphologyDataNL.adjectives, morphologyDataNL.addSuffixes.stemModifications, "zuiver" ) ).toEqual( [
"zuiverder",
"zuiverders",
"zuiverdere",
"zuiverderes",
"zuiverst",
"zuiverste",
"zuivere",
"zuivers",
] );
], );
} );
it( "Does not make a partitive form if stem ends with an s", () => {
expect( addAllAdjectiveSuffixes( morphologyDataNL.adjectives, morphologyDataNL.addSuffixes.stemModifications, "boos" ) ).toEqual( [
Expand All @@ -176,7 +164,7 @@ describe( "Adds adjective suffixes", () => {
"boost",
"booste",
"boze",
] );
], );
} );
it( "Adds all adjective suffixes to a given Dutch stem that requires stem modifications", () => {
expect( addAllAdjectiveSuffixes( morphologyDataNL.adjectives, morphologyDataNL.addSuffixes.stemModifications, "hoog" ) ).toEqual( [
Expand All @@ -188,31 +176,6 @@ describe( "Adds adjective suffixes", () => {
"hoogste",
"hoge",
"hoogs",
] );
} );
it( "Adds all adjective suffixes to a given Dutch stem that normally requires stem modifications but doesn't", () => {
expect( addAllAdjectiveSuffixes( morphologyDataNL.adjectives, morphologyDataNL.addSuffixes.stemModifications, "nobel" ) ).toEqual( [
"nobeler",
"nobelers",
"nobelere",
"nobeleres",
"nobelst",
"nobelste",
"nobele",
"nobels",
] );
} );
it( "Adds all adjective suffixes to a given Dutch stem that normally requires stem modifications but doesn't " +
"Input: word ends in one of the words in the exception list (verb)", () => {
expect( addAllAdjectiveSuffixes( morphologyDataNL.adjectives, morphologyDataNL.addSuffixes.stemModifications, "memorabel" ) ).toEqual( [
"memorabeler",
"memorabelers",
"memorabelere",
"memorabeleres",
"memorabelst",
"memorabelste",
"memorabele",
"memorabels",
] );
], );
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe( "Test for getting the right plural suffixes", () => {
] );
} );
it( "returns the default plural suffix if no suffix could be predicted based on stem ending", () => {
expect( getSuffixes( "bal", morphologyDataNL.nouns.suffixes.pluralSuffixes ) ).toEqual( [
expect( getSuffixes( "groent", morphologyDataNL.nouns.suffixes.pluralSuffixes ) ).toEqual( [
"en",
] );
} );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import checkExceptionsWithFullForms from "../../../src/morphology/morphoHelpers/checkExceptionsWithFullForms";
import getMorphologyData from "../../specHelpers/getMorphologyData";

const morphologyDataNL = getMorphologyData( "nl" ).nl;

describe( "Test for getting the correct stem from full forms exception lists", () => {
it( "return the correct stem when the word checked is listed in the full form exception list", () => {
expect( checkExceptionsWithFullForms( morphologyDataNL.stemming.stemmingExceptionStemsWithFullForms, "stadje" ) ).toEqual( "stad" );
} );
it( "return the correct stem when the word checked is listed in the full form exception list", () => {
expect( checkExceptionsWithFullForms( morphologyDataNL.stemming.stemmingExceptionStemsWithFullForms, "museumpjes" ) ).toEqual( "museum" );
} );
it( "return the correct stem when the word checked is a compound word ending in a word listed in the full form exception list", () => {
expect( checkExceptionsWithFullForms( morphologyDataNL.stemming.stemmingExceptionStemsWithFullForms, "fitnesscentra" ) ).toEqual(
"fitnesscentrum" );
} );
it( "returns null if the word ends in a word from the exception list ('eis'), but the preceding lexical material is shorter" +
" than 2 characters", () => {
expect( checkExceptionsWithFullForms( morphologyDataNL.stemming.stemmingExceptionStemsWithFullForms, "reis" ) ).toEqual( null );
} );
it( "returns null if the word checked is not in the exception list", () => {
expect( checkExceptionsWithFullForms( morphologyDataNL.stemming.stemmingExceptionStemsWithFullForms, "plant" ) ).toEqual( null );
} );
} );
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { flatten } from "lodash-es";
/**
*
* Checks whether a word is on the exception list for which we have full forms. If it is, returns the indicated stem of the word.
*
* @param {Array} fullFormsExceptionList The exception list with full forms to check against.
* @param {string} word The word to check.
*
* @returns {string/null} The created word forms.
*/
export default function( fullFormsExceptionList, word ) {
for ( let i = 0; i < fullFormsExceptionList.length; i++ ) {
const stemAndForms = flatten( fullFormsExceptionList[ i ] );
for ( let j = 0; j < stemAndForms.length; j++ ) {
if ( word.endsWith( stemAndForms[ j ] ) ) {
/*
* Check if the word checked is actually a compound word. e.g. familielid
* The character/s preceding the words in the exception should be at least 2 characters in order to be a valid compound element.
*/
const precedingLexicalMaterial = word.slice( 0, -stemAndForms[ j ].length );
if ( precedingLexicalMaterial.length === 1 ) {
return null;
}
// We only need to return the first index of the array as the stem.
if ( precedingLexicalMaterial.length > 1 ) {
return precedingLexicalMaterial.concat( stemAndForms[ 0 ] );
}
return stemAndForms[ 0 ];
}
}
}
return null;
}