english-determiners
Advanced tools
Comparing version 3.1.7 to 3.1.8
@@ -9,44 +9,62 @@ "use strict"; | ||
exports.getDet = void 0; | ||
function getDet(detType, genderOwner, numberOwner, numberOwned, dist, forceArticlePlural) { | ||
if (detType != 'DEFINITE' && detType != 'INDEFINITE' && detType != 'DEMONSTRATIVE' && detType != 'POSSESSIVE') { | ||
function checkNumberOwned(numberOwned) { | ||
if (numberOwned != 'S' && numberOwned != 'P') { | ||
const err = new Error(); | ||
err.name = 'InvalidArgumentError'; | ||
err.message = `${detType} is not a supported determiner`; | ||
err.message = `numberOwned must be S or P`; | ||
throw err; | ||
} | ||
if (detType === 'POSSESSIVE') { | ||
if (numberOwner != 'P' && genderOwner != 'M' && genderOwner != 'F' && genderOwner != 'N') { | ||
const err = new Error(); | ||
err.name = 'InvalidArgumentError'; | ||
err.message = `genderOwner must be F M or N when POSSESSIVE (unless numberOwner is P)`; | ||
throw err; | ||
} | ||
function getDefinite(numberOwned, forceArticlePlural) { | ||
checkNumberOwned(numberOwned); | ||
switch (numberOwned) { | ||
case 'S': { | ||
return 'the'; | ||
} | ||
if (numberOwner != 'S' && numberOwner != 'P') { | ||
const err = new Error(); | ||
err.name = 'InvalidArgumentError'; | ||
err.message = `numberOwner must be S or P when POSSESSIVE`; | ||
throw err; | ||
case 'P': { | ||
if (forceArticlePlural) { | ||
return 'the'; | ||
} | ||
else { | ||
return ''; | ||
} | ||
} | ||
// istanbul ignore next | ||
default: | ||
return ''; | ||
} | ||
else { | ||
if (numberOwned != 'S' && numberOwned != 'P') { | ||
const err = new Error(); | ||
err.name = 'InvalidArgumentError'; | ||
err.message = `numberOwned must be S or P`; | ||
throw err; | ||
} | ||
function getIndefinite(numberOwned) { | ||
checkNumberOwned(numberOwned); | ||
switch (numberOwned) { | ||
case 'S': { | ||
return 'a'; | ||
} | ||
case 'P': { | ||
return ''; | ||
} | ||
// istanbul ignore next | ||
default: | ||
return ''; | ||
} | ||
switch (detType) { | ||
case 'DEFINITE': | ||
switch (numberOwned) { | ||
case 'S': { | ||
return 'the'; | ||
} | ||
function getDemonstrative(numberOwned, dist) { | ||
checkNumberOwned(numberOwned); | ||
if (!dist) { | ||
dist = 'NEAR'; | ||
} | ||
else if (dist != 'NEAR' && dist != 'FAR') { | ||
const err = new Error(); | ||
err.name = 'InvalidArgumentError'; | ||
err.message = `dist must be NEAR or FAR, here ${dist}`; | ||
throw err; | ||
} | ||
switch (numberOwned) { | ||
case 'S': { | ||
switch (dist) { | ||
case 'NEAR': { | ||
return 'this'; | ||
} | ||
case 'P': { | ||
if (forceArticlePlural) { | ||
return 'the'; | ||
} | ||
else { | ||
return ''; | ||
} | ||
case 'FAR': { | ||
return 'that'; | ||
} | ||
@@ -57,9 +75,10 @@ // istanbul ignore next | ||
} | ||
case 'INDEFINITE': | ||
switch (numberOwned) { | ||
case 'S': { | ||
return 'a'; | ||
} | ||
case 'P': { | ||
switch (dist) { | ||
case 'NEAR': { | ||
return 'these'; | ||
} | ||
case 'P': { | ||
return ''; | ||
case 'FAR': { | ||
return 'those'; | ||
} | ||
@@ -70,39 +89,30 @@ // istanbul ignore next | ||
} | ||
case 'DEMONSTRATIVE': | ||
if (!dist) { | ||
dist = 'NEAR'; | ||
} | ||
else if (dist != 'NEAR' && dist != 'FAR') { | ||
const err = new Error(); | ||
err.name = 'InvalidArgumentError'; | ||
err.message = `dist must be NEAR or FAR, here ${dist}`; | ||
throw err; | ||
} | ||
switch (numberOwned) { | ||
case 'S': { | ||
switch (dist) { | ||
case 'NEAR': { | ||
return 'this'; | ||
} | ||
case 'FAR': { | ||
return 'that'; | ||
} | ||
// istanbul ignore next | ||
default: | ||
return ''; | ||
} | ||
} | ||
case 'P': { | ||
switch (dist) { | ||
case 'NEAR': { | ||
return 'these'; | ||
} | ||
case 'FAR': { | ||
return 'those'; | ||
} | ||
// istanbul ignore next | ||
default: | ||
return ''; | ||
} | ||
} | ||
} | ||
// istanbul ignore next | ||
default: | ||
return ''; | ||
} | ||
} | ||
function getPossessive(genderOwner, numberOwner) { | ||
if (numberOwner != 'P' && genderOwner != 'M' && genderOwner != 'F' && genderOwner != 'N') { | ||
const err = new Error(); | ||
err.name = 'InvalidArgumentError'; | ||
err.message = `genderOwner must be F M or N when POSSESSIVE (unless numberOwner is P)`; | ||
throw err; | ||
} | ||
if (numberOwner != 'S' && numberOwner != 'P') { | ||
const err = new Error(); | ||
err.name = 'InvalidArgumentError'; | ||
err.message = `numberOwner must be S or P when POSSESSIVE`; | ||
throw err; | ||
} | ||
switch (numberOwner) { | ||
case 'S': { | ||
switch (genderOwner) { | ||
case 'M': | ||
return 'his'; | ||
case 'F': | ||
return 'her'; | ||
case 'N': | ||
return 'its'; | ||
// istanbul ignore next | ||
@@ -112,24 +122,6 @@ default: | ||
} | ||
case 'POSSESSIVE': | ||
switch (numberOwner) { | ||
case 'S': { | ||
switch (genderOwner) { | ||
case 'M': | ||
return 'his'; | ||
case 'F': | ||
return 'her'; | ||
case 'N': | ||
return 'its'; | ||
// istanbul ignore next | ||
default: | ||
return ''; | ||
} | ||
} | ||
case 'P': { | ||
return 'their'; | ||
} | ||
// istanbul ignore next | ||
default: | ||
return ''; | ||
} | ||
} | ||
case 'P': { | ||
return 'their'; | ||
} | ||
// istanbul ignore next | ||
@@ -140,3 +132,21 @@ default: | ||
} | ||
function getDet(detType, genderOwner, numberOwner, numberOwned, dist, forceArticlePlural) { | ||
switch (detType) { | ||
case 'DEFINITE': | ||
return getDefinite(numberOwned, forceArticlePlural); | ||
case 'INDEFINITE': | ||
return getIndefinite(numberOwned); | ||
case 'DEMONSTRATIVE': | ||
return getDemonstrative(numberOwned, dist); | ||
case 'POSSESSIVE': | ||
return getPossessive(genderOwner, numberOwner); | ||
default: { | ||
const err = new Error(); | ||
err.name = 'InvalidArgumentError'; | ||
err.message = `${detType} is not a supported determiner`; | ||
throw err; | ||
} | ||
} | ||
} | ||
exports.getDet = getDet; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "english-determiners", | ||
"version": "3.1.7", | ||
"version": "3.1.8", | ||
"description": "English determiners", | ||
@@ -57,3 +57,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "a501d0473fdc12407624be4eac58618e1702dcdc" | ||
"gitHead": "dfcd8d00b365feeb9aeda8ab0b311f12b94ac630" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21540
156