Meilleure extraction du nom
- cas des entités non incarnées
This commit is contained in:
parent
ab61d5991d
commit
1f564e0d89
@ -491,21 +491,27 @@ export class RdDStatBlockParser {
|
||||
}
|
||||
|
||||
static extractName(actorType, statString) {
|
||||
switch (actorType) {
|
||||
case "personnage":
|
||||
// Check if ',né le' is present
|
||||
let namePersonnage = "Importé"
|
||||
if (statString.includes(", né")) {
|
||||
// Name is all string before first comma ','
|
||||
namePersonnage = XRegExp.exec(statString, XRegExp("(?<value>[\\p{Letter}\\'\\-\\s\\d]+),", 'giu'));
|
||||
} else {
|
||||
namePersonnage = XRegExp.exec(statString, XRegExp("(?<value>[\\p{Letter}\\'\\-\\s\\d]+)\\s+TAILLE", 'giu'));
|
||||
}
|
||||
if (namePersonnage?.value) {
|
||||
return Misc.upperFirst(namePersonnage?.value.toLowerCase());
|
||||
}
|
||||
if (actorType == "personnage") {
|
||||
// Check if ',né le' is present
|
||||
let namePersonnage = "Importé"
|
||||
if (statString.includes(", né")) {
|
||||
// Name is all string before first comma ','
|
||||
namePersonnage = XRegExp.exec(statString, XRegExp("(?<value>[\\p{Letter}\\'\\-\\s\\d]+),", 'giu'));
|
||||
} else {
|
||||
namePersonnage = XRegExp.exec(statString, XRegExp("(?<value>[\\p{Letter}\\'\\-\\s\\d]+)\\s+TAILLE", 'giu'));
|
||||
}
|
||||
if (namePersonnage?.value) {
|
||||
return Misc.upperFirst(namePersonnage?.value.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
const name = XRegExp.exec(statString, XRegExp("(?<value>.+)\\s+taille", 'giu'));
|
||||
if (actorType == "entite") {
|
||||
if (!(name?.value)) {
|
||||
const nameEntiteReve = XRegExp.exec(statString, XRegExp("(?<value>.+)\\s+rêve", 'giu'));
|
||||
return Misc.upperFirst(nameEntiteReve?.value || "Importé");
|
||||
}
|
||||
}
|
||||
return Misc.upperFirst(name?.value || "Importé");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user