yoastseo
Version:
Yoast client-side content analysis
63 lines (60 loc) • 2.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _lodash = require("lodash");
var _yoastseo = require("yoastseo");
var _functionWords = require("../config/functionWords");
var _nonParticiples = _interopRequireDefault(require("../config/internal/nonParticiples"));
var _getParticiples = _interopRequireDefault(require("../helpers/internal/getParticiples"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const {
directPrecedenceException,
values
} = _yoastseo.languageProcessing;
const {
Clause
} = values;
/**
* Creates a Clause object for the Dutch language.
*/
class DutchClause 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 and there is an auxiliary present, the clause is passive.
*
* @returns {void}
*/
checkParticiples() {
const foundParticiples = this.getParticiples().filter(participle => {
return !(0, _lodash.includes)(_nonParticiples.default, participle) && !this.hasNonParticipleEnding(participle) && !directPrecedenceException(this.getClauseText(), participle, _functionWords.cannotDirectlyPrecedePassiveParticiple);
});
this.setPassive(foundParticiples.length > 0);
}
/**
* Checks whether a found participle has a non-participle ending and is therefore not really a participle.
*
* @param {string} participle The participle to check.
*
* @returns {boolean} Returns true if the participle has a non-participle ending, otherwise returns false.
*/
hasNonParticipleEnding(participle) {
return /\S+(heid|teit|tijd)($|[ \n\r\t.,'()"+\-;!?:/»«‹›<>])/ig.test(participle);
}
}
var _default = exports.default = DutchClause;
//# sourceMappingURL=Clause.js.map