Skip to content

Commit

Permalink
Don't return complex words if premium data is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
FAMarfuaty committed Sep 29, 2023
1 parent 242b0cb commit e5772c1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function checkIfWordIsComplex( config, word, premiumData ) {
// All words are converted to lower case before processing to avoid excluding complex words that start with a capital letter.
word = word.toLowerCase();

// The German word is not complex if its length is 10 characters or less.
// The German word is not complex if its length is 10 characters or fewer.
if ( word.length <= lengthLimit ) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,22 @@ const getComplexWords = function( currentSentence, researcher ) {
// Filters out function words because function words are not complex.
// Words are converted to lowercase before processing to avoid excluding function words that start with a capital letter.
const words = allWords.filter( word => ! ( checkIfWordIsFunction ? checkIfWordIsFunction( word ) : functionWords.includes( word ) ) );
const results = [];
const result = {
complexWords: [],
sentence: currentSentence,
};

if ( ! premiumData ) {
return result;
}

words.forEach( word => {
if ( checkIfWordIsComplex( wordComplexityConfig, word, premiumData ) ) {
results.push( word );
result.complexWords.push( word );
}
} );

return {
complexWords: results,
sentence: currentSentence,
};
return result;
};

/**
Expand Down

0 comments on commit e5772c1

Please sign in to comment.