yoastseo
Version:
Yoast client-side content analysis
90 lines (86 loc) • 3.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _lodash = require("lodash");
var _getParticiples = _interopRequireDefault(require("../helpers/internal/getParticiples.js"));
var _yoastseo = require("yoastseo");
var _functionWords = require("../config/functionWords");
var _exceptionsParticiplesActive = require("../config/internal/exceptionsParticiplesActive");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const {
precedenceException,
directPrecedenceException,
values
} = _yoastseo.languageProcessing;
const {
Clause
} = values;
/**
* Creates a Clause object for the French language.
*/
class FrenchClause extends Clause {
/**
* Constructor.
*
* @param {string} clauseText The text of the clause.
* @param {Array} auxiliaries The auxiliaries.
*
* @constructor
*/
constructor(clauseText, auxiliaries) {
super(clauseText, auxiliaries);
this._participles = (0, _getParticiples.default)(this.getClauseText());
this.checkParticiples();
}
/**
* Checks if any exceptions are applicable to this participle that would result in the clause not being passive.
* If no exceptions are found, the clause is passive.
*
* @returns {boolean} Returns true if no exception is found.
*/
checkParticiples() {
const clause = this.getClauseText();
const passiveParticiples = this.getParticiples().filter(participle => !participle.startsWith("l'") && !participle.startsWith("d'") && !(0, _lodash.includes)(_exceptionsParticiplesActive.others, participle) && !this.isOnAdjectiveVerbExceptionList(participle) && !this.isOnNounExceptionList(participle) && !directPrecedenceException(clause, participle, _functionWords.cannotDirectlyPrecedePassiveParticiple) && !precedenceException(clause, participle, _functionWords.cannotBeBetweenPassiveAuxiliaryAndParticiple));
this.setPassive(passiveParticiples.length > 0);
}
/**
* Checks whether the participle is on an exception list of words that look like participles but are adjectives or verbs.
*
* @param {string} participle The participle to check.
*
* @returns {boolean} Whether or not the participle is on the adjective and verb exception list.
*/
isOnAdjectiveVerbExceptionList(participle) {
if (_exceptionsParticiplesActive.adjectivesVerbs.includes(participle)) {
return true;
}
// Checks for and removes a suffix and checks the exception list again.
if (participle.endsWith("es")) {
participle = participle.slice(0, -2);
} else if (participle.endsWith("e") || participle.endsWith("s")) {
participle = participle.slice(0, -1);
}
return _exceptionsParticiplesActive.adjectivesVerbs.includes(participle);
}
/**
* Checks whether the participle is on an exception list of words that look like participles but are nouns.
*
* @param {string} participle The participle to check.
*
* @returns {boolean} Whether or not the participle is on the noun exception list.
*/
isOnNounExceptionList(participle) {
if (_exceptionsParticiplesActive.nouns.includes(participle)) {
return true;
}
// Checks for and removes a suffix and checks the exception list again.
if (participle.endsWith("s")) {
participle = participle.slice(0, -1);
}
return _exceptionsParticiplesActive.nouns.includes(participle);
}
}
var _default = exports.default = FrenchClause;
//# sourceMappingURL=Clause.js.map