Skip to content

Commit

Permalink
Merge pull request #21788 from Yoast/dont-use-slice-or-splice-to-crea…
Browse files Browse the repository at this point in the history
…te-disability-rules-lists

Improve the way that lists used for disability assessment rules are created
  • Loading branch information
FAMarfuaty authored Nov 6, 2024
2 parents 8c68216 + d276d98 commit c645521
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
filteredAuxiliaries as filteredPassiveAuxiliaries,
notFilteredAuxiliaries as notFilteredPassiveAuxiliaries,
all as passiveAuxiliaries,
} from "./internal/passiveVoiceAuxiliaries.js";
import { singleWords as transitionWords } from "./transitionWords.js";
import transformWordsWithHyphens from "../../../helpers/transform/transformWordsWithHyphens";
Expand Down Expand Up @@ -139,7 +138,7 @@ export const filteredAtBeginningAndEnding = transformWordsWithHyphens( [].concat

// These word categories are filtered everywhere within word combinations.
export const filteredAnywhere = transformWordsWithHyphens( [].concat( transitionWords, adverbialGenitives, personalPronounsNominative,
personalPronounsAccusative, reflexivePronouns, interjections, cardinalNumerals, filteredPassiveAuxiliaries, otherAuxiliaries,
personalPronounsAccusative, reflexivePronouns, interjections, cardinalNumerals, passiveAuxiliaries, otherAuxiliaries,
copula, interviewVerbs, delexicalizedVerbs, indefinitePronouns, correlativeConjunctions, subordinatingConjunctions, interrogativeDeterminers,
interrogativePronouns, interrogativeProAdverbs, locativeAdverbs, miscellaneous, prepositionalAdverbs, pronominalAdverbs,
recipeWords, timeWords, vagueNouns ) );
Expand All @@ -163,17 +162,17 @@ export const cannotBeBetweenPassiveAuxiliaryAndParticiple = transformWordsWithHy
export const nonNouns = transformWordsWithHyphens( [].concat( articles, cardinalNumerals, ordinalNumerals, demonstrativePronouns,
possessivePronouns, reflexivePronouns, personalPronounsNominative, personalPronounsAccusative, quantifiers, indefinitePronouns, continuousVerbs,
indefinitePronounsPossessive, interrogativeDeterminers, interrogativePronouns, interrogativeProAdverbs,
pronominalAdverbs, locativeAdverbs, adverbialGenitives, prepositionalAdverbs, filteredPassiveAuxiliaries, notFilteredPassiveAuxiliaries,
otherAuxiliaries, copula, prepositions, coordinatingConjunctions, correlativeConjunctions, subordinatingConjunctions, interviewVerbs,
pronominalAdverbs, locativeAdverbs, adverbialGenitives, prepositionalAdverbs, passiveAuxiliaries, otherAuxiliaries, copula, prepositions,
coordinatingConjunctions, correlativeConjunctions, subordinatingConjunctions, interviewVerbs,
transitionWords, additionalTransitionWords, intensifiers, delexicalizedVerbs, interjections, generalAdjectivesAdverbs,
recipeWords, miscellaneous, titlesFollowing ) );

// This export contains all of the above words.
export const all = transformWordsWithHyphens( [].concat( articles, cardinalNumerals, ordinalNumerals, demonstrativePronouns, possessivePronouns,
reflexivePronouns, personalPronounsNominative, personalPronounsAccusative, quantifiers, indefinitePronouns, continuousVerbs,
indefinitePronounsPossessive, interrogativeDeterminers, interrogativePronouns, interrogativeProAdverbs,
pronominalAdverbs, locativeAdverbs, adverbialGenitives, prepositionalAdverbs, filteredPassiveAuxiliaries, notFilteredPassiveAuxiliaries,
otherAuxiliaries, copula, prepositions, coordinatingConjunctions, correlativeConjunctions, subordinatingConjunctions, interviewVerbs,
pronominalAdverbs, locativeAdverbs, adverbialGenitives, prepositionalAdverbs, passiveAuxiliaries, otherAuxiliaries, copula,
prepositions, coordinatingConjunctions, correlativeConjunctions, subordinatingConjunctions, interviewVerbs,
transitionWords, additionalTransitionWords, intensifiers, delexicalizedVerbs, interjections, generalAdjectivesAdverbs,
recipeWords, vagueNouns, miscellaneous, timeWords, titlesPreceding, titlesFollowing ) );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
// These auxiliaries are filtered from the beginning of word combinations in the prominent words.
export const filteredAuxiliaries = [
// All lists except for the `other` one are also used to create rules for some inclusive language assessments.
// The auxiliaries are categorized into different lists because this categorization is needed for the inclusive language rules.
export const formsOfToBe = [
"am",
"is",
"are",
"was",
"were",
"been",
"get",
"gets",
"got",
"gotten",
"be",
"she's",
"he's",
Expand All @@ -19,20 +16,29 @@ export const filteredAuxiliaries = [
"they're",
"you're",
"that's",
"being",
];

export const negatedFormsOfToBe = [
"isn't",
"weren't",
"wasn't",
"aren't",
];

// These auxiliaries are not filtered from the beginning of word combinations in the prominent words.
export const notFilteredAuxiliaries = [
"being",
export const formsOfToGet = [
"get",
"gets",
"got",
"gotten",
"getting",
];

export const other = [
"having",
"what's",
];

export const all = filteredAuxiliaries.concat( notFilteredAuxiliaries );
export const all = formsOfToBe.concat( negatedFormsOfToBe, formsOfToGet, other );

export default all;
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import passiveAuxiliaries from "../../../../languageProcessing/languages/en/config/internal/passiveVoiceAuxiliaries";
import { formsOfToBe, negatedFormsOfToBe, formsOfToGet } from "../../../../languageProcessing/languages/en/config/internal/passiveVoiceAuxiliaries";
import { flatMap } from "lodash";

const intensifiersAndAdverbs = [ "so", "very", "a bit", "really", "pretty", "kind of", "that", "too", "totally", "completely", "absolutely", "even",
"also", "as" ];
const formsOfToDrive = [ "driving", "drive", "drove", "drives", "driven" ];
const objectPronouns = [ "me", "you", "them", "him", "her", "someone", "somebody", "anyone", "anybody", "everyone", "everybody" ];
// Remove 'having' and 'what's' from the auxiliaries. We don't want to use them for any rules.
const formsOfToBeAndToGet = passiveAuxiliaries.slice( 0, -2 );
/*
* Move the negated forms ("isn't", "weren't", "wasn't", "aren't") to a separate array "negatedFormsOfToBe".
* The .splice() method is a mutating method.
* It means that after invoking this method on "formsOfToBeAndToGet" list, the "formsOfToBeAndToGet" will also be mutated.
* In this case, the negated forms ("isn't", "weren't", "wasn't", "aren't") will also be removed from the array.
*/
const negatedFormsOfToBe = formsOfToBeAndToGet.splice( 19, 4 );
const formsOfToBeAndToGet = formsOfToBe.concat( formsOfToGet );

/**
* Creates an array of all possible combinations of strings from two arrays.
Expand All @@ -40,10 +32,10 @@ export const formsOfToBeWithOptionalIntensifier = combinationsOfToBeAndIntensifi
* Create an array of strings that should precede the negated version of 'crazy about'.
* It includes all forms of 'to be/to get', followed by 'not/'nt' and an optional intensifier or specific adverb (e.g., 'is not', 'aren't even').
*/
let formsOfToBeNot = flatMap( formsOfToBeAndToGet, verbTobe => `${verbTobe} not` );
formsOfToBeNot = formsOfToBeNot.concat( negatedFormsOfToBe );
const combinationsOfToBeNotAndIntensifier = createCombinationsFromTwoArrays( formsOfToBeNot, intensifiersAndAdverbs );
export const formsOfToBeNotWithOptionalIntensifier = combinationsOfToBeNotAndIntensifier.concat( formsOfToBeNot );
let negatedFormsOfToBeAndToGet = flatMap( formsOfToBeAndToGet, verb => `${verb} not` );
negatedFormsOfToBeAndToGet = negatedFormsOfToBeAndToGet.concat( negatedFormsOfToBe );
const combinationsOfToBeNotAndIntensifier = createCombinationsFromTwoArrays( negatedFormsOfToBeAndToGet, intensifiersAndAdverbs );
export const formsOfToBeNotWithOptionalIntensifier = combinationsOfToBeNotAndIntensifier.concat( negatedFormsOfToBeAndToGet );

/*
* Create an array of strings that should precede 'OCD'.
Expand Down

0 comments on commit c645521

Please sign in to comment.