Improved species matching

This commit is contained in:
Mr. Stallion 2020-10-18 17:52:56 -05:00
parent 01ca2ce344
commit d91f44d0db
5 changed files with 295 additions and 71 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## 1.3.0
* Improved species search and matching
## 1.2.0
* Hide/show current character profile with Ctrl+P or Command+P
* Navigate back and forward in character profile view history

View File

@ -11,9 +11,9 @@
v-model="data[item]" :placeholder="l('filter')" :title="l('characterSearch.' + item)" :options="options[item]" :key="item">
</filterable-select>
<filterable-select v-model="data.species" :multiple="true" :placeholder="l('filter')"
<filterable-select class="species-filter" v-model="data.species" :multiple="true" :placeholder="l('filter')"
:title="l('characterSearch.species')" :options="options.species">
<template slot-scope="s">{{s.option.name}}</template>
<template slot-scope="s">{{s.option.shortName}} <small>{{s.option.details}}</small></template>
</filterable-select>
<div v-if="searchString" class="search-string">
@ -61,7 +61,7 @@
import {EventBus} from './preview/event-bus';
import CharacterSearchHistory from './CharacterSearchHistory.vue';
import { Matcher } from '../learn/matcher';
import { Species, speciesNames } from '../learn/matcher-types';
import { Species, speciesMapping, speciesNames } from '../learn/matcher-types';
type Options = {
kinks: SearchKink[],
@ -250,27 +250,38 @@
return !!_.find(this.data.species, (s: SearchSpecies) => (s.id === species));
}
getSpeciesOptions(): SearchSpecies[] {
const species = _.map(
_.filter(Species, (s) => (_.isString(s))) as unknown[] as string[],
(speciesName: keyof typeof Species): SearchSpecies => {
const speciesId: number = Species[speciesName];
speciesMapping,
(keywords: string[], speciesIdStr: Species): SearchSpecies => {
// const speciesId: number = Species[speciesName];
const details = `${keywords.join(', ').substr(0, 24)}...`;
const speciesId = parseInt(speciesIdStr as any, 10);
if (speciesId in speciesNames) {
const name = `${speciesNames[speciesId].substr(0, 1).toUpperCase()}${speciesNames[speciesId].substr(1)}`;
return {
name: `${speciesNames[speciesId].substr(0, 1).toUpperCase()}${speciesNames[speciesId].substr(1)} (species)`,
details,
name: `${name} (species)`,
shortName: name,
id: speciesId
};
}
const speciesName = Species[speciesId];
return {
details,
name: `${speciesName}s (species)`,
shortName: `${speciesName}s`,
id: speciesId
};
}
) as unknown[] as SearchSpecies[];
// console.log('SPECIES', species);
return _.sortBy(species, 'name');
}
@ -364,6 +375,12 @@
<style lang="scss">
.character-search {
.species-filter {
small {
color: var(--tabSecondaryFgColor)
}
}
.dropdown {
margin-bottom: 10px;
}

View File

@ -144,7 +144,7 @@ export interface Logs {
}
export type SearchKink = {id: number, name: string, description: string};
export type SearchSpecies = {id: number, name: string};
export type SearchSpecies = {id: number, name: string, shortName: string, details: string};
export interface SearchData {
kinks: SearchKink[]

View File

@ -153,19 +153,32 @@ export enum Species {
Minotaur = 12121212,
Giraffe = 13131313,
Rhinoceros = 14141414
Rhinoceros = 14141414,
Suidae = 15151515,
Herpestidae = 16161616,
Were = 17171717,
Erinaceidae = 18181818,
Elephantidae = 19191919,
Camielidae = 20202020,
Hippopotamidae = 21212121,
Hub = 22222222,
Pinniped = 23232323,
Hybrid = 24242424
}
export const nonAnthroSpecies = [
Species.Human, Species.Elf, Species.Orc, Species.Humanoid,
Species.Demon, Species.Divinity, Species.Alien, Species.Robot,
Species.Fae, Species.Vampire
Species.Fae, Species.Vampire, Species.Monster, Species.Pokemon,
Species.Hub
];
export const mammalSpecies = [Species.Equine, Species.Feline, Species.Canine, Species.Vulpine, Species.Cervine, Species.Lapine,
Species.Musteline, Species.Procyon, Species.Rodent, Species.Ursine, Species.MarineMammal, Species.Primate,
Species.Anthro, Species.Bovine, Species.Caprinae, Species.Marsupial, Species.Hyaenidae, Species.Minotaur,
Species.Bat, Species.Mephitidae, Species.Taur, Species.Giraffe, Species.Rhinoceros];
Species.Bat, Species.Mephitidae, Species.Taur, Species.Giraffe, Species.Rhinoceros, Species.Suidae,
Species.Herpestidae, Species.Were, Species.Erinaceidae, Species.Elephantidae, Species.Camielidae, Species.Hippopotamidae,
Species.Pinniped, Species.Hybrid];
export interface SpeciesMap {
[key: number]: string[];
@ -180,59 +193,196 @@ export const speciesNames: SpeciesStrMap = {
[Species.Elf]: 'elves',
[Species.Fish]: 'fishes',
[Species.Mephitidae]: 'mephitis',
[Species.Rhinoceros]: 'rhinoceros'
[Species.Rhinoceros]: 'rhinoceros',
[Species.Suidae]: 'swine'
};
export const likelyHuman: SpeciesMap = {
[Species.Human]: ['bimbo', 'witch', 'wizard', 'gyaru', 'milf', '.*slut', 'black', 'azarathian', 'kryptonian', 'mensch', 'thot',
'sister', 'brother', 'mother', 'father', 'fuckpig', 'hero', 'she-stud', 'college', 'cutie',
'bimboi', 'homo', 'streamer', '.*human', 'femboy', 'nord', 'norse', 'norseman', 'man', 'whitebo[yi]', '.*bo[yi].*', '.*girl.*',
'french', 'whore', 'slutty', 'adult', 'otaku', 'cumdump', 'thug', 'magus',
'sapien[s]?',
'paladin', 'knight',
'male', 'female', 'shemale',
'aasimar', 'astartes', 'saiyan', 'echani', 'cathar', 'shikaisen', 'cosplayer'
]
};
// armadillo
// anteater
// red panda / akai pandamimi
// echidna
export const speciesMapping: SpeciesMap = {
[Species.Human]: ['human', 'humanoid', 'angel', 'android', 'african american', 'africanamerican', 'woman', 'dothraki', 'homo sapien', 'homosapien', 'homosapian', 'hooman', 'hoomin', 'hooomin'],
[Species.Humanoid]: ['satyr', 'gnome', 'dwarf', 'halfling', 'tiefling', 'humanoid'],
[Species.Equine]: ['horse', 'stallion', 'mare', 'filly', 'equine', 'shire', 'donkey', 'mule', 'zebra', 'pony', 'unicorn', 'clydesdale', 'shire',
'appaloosa', 'friesian', 'draft', 'draught', 'alicorn', 'amazon', 'amazonian', 'horsie', 'hoss', 'pegasus', 'colt', 'filly'],
[Species.Feline]: ['cat', 'kitten', 'catgirl', 'neko', 'tiger', 'puma', 'lion', 'lioness',
'tigress', 'feline', 'jaguar', 'cheetah', 'lynx', 'leopard', 'cougar', 'kitty', 'migote', 'miqo\'te', 'miqote', 'ocelot',
'sabertooth', 'saber tooth', 'tabby', 'liger', 'serval'],
[Species.Canine]: ['dog', 'wolf', 'dingo', 'coyote', 'jackal', 'canine', 'doberman', 'husky', 'hound', 'akita', 'pitbull', 'pit bull', 'terrier',
'bull terrier', 'australian shepherd', 'australian shepard', 'german shepherd', 'german shepard', 'malinois', 'woof', 'labrador', 'collie',
'canis', 'canid', 'chihuahua', 'poodle', 'chinchilla', 'chowchow', 'corgi', 'anubis', 'anubian', 'dalmatian', 'inumimi', 'lupine', 'malamute', 'mastiff',
'mutt', 'rottweiler', 'shih tzu', 'worgen'],
[Species.Vulpine]: ['fox', 'fennec', 'kitsune', 'vulpine', 'vixen'],
[Species.Avian]: ['bird', 'gryphon', 'phoenix', 'roc', 'chimera', 'avian', 'albatross', 'cockatiel', 'dove', 'eagle', 'owl', 'penguin', 'raven'],
[Species.Amphibian]: ['salamander', 'frog', 'toad', 'newt', 'amphibian'],
[Species.Cervine]: ['deer', 'elk', 'moose', 'cervid', 'cervine', 'caribou', 'reindeer', 'doe', 'stag'],
[Species.Insect]: ['bee', 'wasp', 'spider', 'scorpion', 'ant', 'insect'],
[Species.Lapine]: ['bunny', 'rabbit', 'hare', 'lapine'],
[Species.Dragon]: ['dragon', 'drake', 'wyvern', 'draconian'],
[Species.Demon]: ['demon', 'daemon', 'deamon', 'demoness', 'demonkin', 'devil', 'succubus', 'incubus', 'baphomet'],
[Species.Musteline]: ['mink', 'ferret', 'weasel', 'stoat', 'otter', 'wolverine', 'marten', 'musteline'],
[Species.Procyon]: ['raccoon', 'racoon', 'coatimund', 'longtail', 'procyon'],
[Species.Rodent]: ['rat', 'mouse', 'chipmunk', 'squirrel', 'rodent', 'maus'],
[Species.Ursine]: ['bear', 'panda', 'black bear', 'brown bear', 'polar bear', 'ursine'],
[Species.MarineMammal]: ['whale', 'killer whale', 'dolphin'],
[Species.Primate]: ['monkey', 'ape', 'chimp', 'chimpanzee', 'gorilla', 'lemur', 'silverback'],
[Species.Divinity]: ['god', 'goddess', 'demigod', 'demigoddess', 'demi-god', 'demi-goddess'],
[Species.Elf]: ['elf', 'e l f', 'drow', 'draenei', 'draenai', 'kaldorei', 'sindorei'],
[Species.Fish]: ['fish', 'shark', 'great white', 'sergal', 'elven'],
[Species.Orc]: ['orc'],
[Species.Reptile]: ['chameleon', 'anole', 'alligator', 'aligator', 'snake', 'crocodile', 'lizard', 'gator', 'gecko', 'reptile', 'reptilian'],
[Species.Anthro]: ['anthro', 'anthropomorphic'],
[Species.Bovine]: ['cow', 'bovine', 'bison', 'antelope', 'gazelle', 'oryx', 'black angus', 'bull', 'ox'],
[Species.Caprinae]: ['sheep', 'goat', 'ibex', 'takin', 'bharal', 'goral', 'serow', 'lamb'],
[Species.Marsupial]: ['opossum', 'possum', 'kangaroo', 'roo', 'koala', 'wombat'],
[Species.Hyaenidae]: ['hyena'],
[Species.Anthro]: ['anthro', 'anthropomorphic', 'kemono', 'kemomimi', 'kemonomimi', 'furry'],
[Species.Human]: ['human.*', 'homo[ -]?sapien', '𝖧𝗎𝗆𝖺𝗇', 'woman', 'dothraki', 'amazon', 'african[ -]?american',
'homo[ -]?sapian', 'hooman', 'hoomin', 'hooomin', 'humaine?', 'amazonian', 'latina', 'latino',
'nephilim', 'angel', 'nephalem', 'archangel'
],
[Species.Elf]: ['drow', 'draenei', 'dunmer', 'blutelf', 'draenai', 'elf.*', 'drow.*', 'e l f', 'e-l-f', 'sin\'?dorei', 'kal\'?dorei',
'elves', 'ᴇʟғ', 'elven', 'elfe', 'nachtelfe?', 'elvish', 'ren\'?dorei', 'quel\'?dorei', 'hal[bf][ -]elf', '.*elf', 'waldelfe',
'shal\'?dorei', 'san\'?layn'
],
[Species.Canine]: ['dog', 'dingo', 'coyote', 'jackal', 'husky', 'canine', 'wolf.*', 'doberman[n]?', 'hound', 'akita', 'pit ?bull',
'terrier', 'bull[ -]?terrier', 'australian[ -]?shepherd', 'australian[ -]?shep[h]?ard', 'german[ -]?shep[h]?erd',
'german[ -]?shep[h]?ard', 'malinois', 'woof', 'labrador', 'collie', 'canis', 'canid', 'chihuahua', 'poodle', 'chinchilla',
'chow[ -]?chow', 'corgi', 'anubis', 'beagle', 'german[ -]?shep', '.*wolf', 'direwolf', 'pointer',
'anubian', 'dalmatian', 'dalmation', 'inumimi', 'lupine', 'malamute', 'mastiff', 'mutt', 'rottweill?er', 'shih[ -]?tzu', 'worgen',
'vallhund', 'puppy', 'okami', 'great[ -]?dane', 'golden[ -]?(retriever|lab|labrador)', 'cocker[ -]?spaniel', 'samoyed', 'awoo',
'borzoi', 'spaniel', 'ookamimimi', 'jakkarumimi', 'chinchiramimi', 'woffo', 'wuff', 'wolfdog', 'setter',
'🐶', '🐺', '🐕', '🐩', 'aussie[ -]?doodle', 'shiba', 'inu', 'veil[ -]?hound', 'timber[ -]?wolf', 'hell[ -]?hound', 'hound',
'wolfess', 'latrans', 'dog[ -]?(girl|bo[yi][e]?)', 'wolf[ -]?(girl|bo[yi][e]?)', 'doggie', 'doggy', 'canis', 'fenrir', 'v[aá]na[r]?gand[r]?',
'doggo', 'barghest', 'barguest', 'crux', 'ᴡᴏʟғ', '𝗪𝗼𝗹𝗳', '𝙳𝚘𝚐', 'dire[ -]?hound'],
[Species.Equine]: ['horse', 'zebra', 'pony', 'donkey', 'stallion', 'mare', 'filly', 'equine', 'shire', 'mule', 'zeeb', 'pon[yi][ -]?bo[yi]',
'unicorn', 'clydesdale', 'shire', 'appaloosa', 'friesian', 'draft', 'draught', 'alicorn', 'horsie', 'hoss', 'pegasus', 'colt',
'filly', 'neigh', 'dullahan', 'tikbalang', 'gypsy[ -]?vanner', 'ardenne[r]?', 'ardennais[e]?', 'pony[ -]?(girl|bo[yi][e]?)',
'cream[ -]?draft', 'belgian[ -]?draft', 'saddle[ -]?bred', 'warm[ -]?blood', 'marsh tacky', 'fox[ -]?trotter', 'morab',
'saddle[ -]?horse', 'walkaloosa', 'welara', 'tiger[ -]?horse', 'horsekin', 'pone',
'horse[ -]?(girl|bo[yi][e]?)', 'umamimi', 'shimaumamimi', 'thestral', 'pegusus',
'mustang', 'horse.*', '.*horse', 'equus', 'kelpie', 'kuranta', 'zonkey',
'🐴', '🦓', '🐎'],
[Species.Feline]: ['cat', 'tiger.*', 'puma', 'lion.*', 'kitten', 'cat[ -]?(girl|bo[yi][e]?)', 'neko', 'neko[ -]?mimi', 'lioness', 'panther',
'panthress', 'tigress', 'feline', 'jaguar', 'cheetah', 'lynx', 'leopard', 'cougar', 'kitty', 'migo\'?te', 'miqo\'?te', 'ocelot',
'saber[ -]?tooth', 'tabby', 'serval', 'russian[ -]?blue', 'thunderian', 'meow', 'lombax', 'domestic[ -]?shorthair',
'british[ -]?shorthair', 'oriental[ -]?shorthair', 'american[ -]?shorthair', 'burmese', 'maine[ -]?coon', 'korat', 'ragdoll',
'ocicat', 'chartreux', 'german[ -]?rex', 'turkish[ -]?van', 'ragamuffin', 'norwegian[ -]?forest[ -]?(cat)?',
'exotic[ -]?shorthair', 'khajiit', 'catamount', 'cat[ -]?person', 'tetton', 'tigre', 'calico', 'caracal', 'tabaxi', 'housecat',
'kodkod', 'karotanta', 'siamese', 'felis', 'catus', 'nekomata', 'nekomimi', 'trianii', 'caitian', 'catto', '.*cat', 'toramimi',
'shishimimi', 'pansamimi', 'hyoumimi', 'mytharii', 'felinid', 'kitteh', 'cat[ -]folk', 'chat', 'lionkin', 'tigerkin',
'liger', 'tigon',
'🐅', '🐆', '🐯', '🦁', '🐈'],
[Species.Vulpine]: ['fox', 'fennec', 'vixen', 'vulpine', 'fox.*', 'fennec', 'kitsune.*', 'kistune', 'gumiho', 'kumiho',
'nogitsune', 'yako', '🦊', 'fox[ -]?(girl|bo[yi][e]?)', 'vulpes', 'silver[ -]?fox', 'arctic[ -]?fox', 'fennec[ -]?fox', 'red[ -]?fox',
'cape[ -]?fox', 'ninetails', 'ninetales', 'vulpo', 'vulpera', 'kitsunemimi', 'foxkin', 'fire[ -]?fox'],
[Species.Dragon]: ['dragon.*', 'drake', 'wyvern', 'felkin', 'night[ -]?fury', 'draconian', 'dragonn?ess', 'draconic', 'dragovian',
'🐉', 'sea[ -]?dragon', 'doragonmimi', 'doragon', 'half[ -]dragon', 'dragonkin'
],
[Species.Reptile]: ['lizard', 'snake', 'crocodile', 'alligator', 'chameleon', 'anole', 'aligator', 'snake.*', 'lizard', 'gator',
'gecko', 'reptile', 'reptilian', 'scaly', 'scale[ -]?born', 'argonian', 'saxhleel', 'skink', 'cobra', 'turtle', 'tortoise',
'nope[ -]rope', 'anaconda', 'python', 'lizardkin', 'lizard[ -]?folk', 'yuan[ -]?ti',
'🐍'],
[Species.Pokemon]: ['charizard', 'charmander', 'pikachu', 'digimon', 'renamon', 'eevee', 'gardev(oi|io)r', 'absol', 'aggron',
'jolteon', 'lopunny', 'raichu', 'scyther', 'blaziken', 'lucario', 'gengar', 'mudsdale', 'mewtwo', 'glaceon', 'pokemon',
'croconaw', 'rattata', 'toxtricity', 'audino', 'sandslash', 'luxray', 'samurott', 'pokémon', 'riolu', 'greninja',
'meowstick', 'alolan', 'sylveon', 'arcanine', 'zebstrika', 'rapidash', 'umbreon', 'litten', 'vulpix', 'groudon',
'gothitelle', 'kecleon', 'quagsire', 'garchomp', 'mismagius', 'zigzagoon', 'sceptile', 'joltik', 'cinderace',
'hypnomade', 'furfrou', 'flareon', 'zeraora', 'mudkip', 'nidoking', 'zorua', 'salamence', 'lycanrock?',
'dewott', 'delcatty', 'braixen', 'zacian', 'fennekin', 'kirlia', 'cinccino', 'growlithe', 'shaymin', 'salazzle',
'vaporeon', 'reshiram', 'quilava', 'decidueye', 'marshadow', 'weavile',
// digimon
'gatomon'
],
[Species.Amphibian]: ['salamander', 'frog', 'toad', 'newt', 'amphibian', 'axolotl'],
[Species.Avian]: ['bird', 'gryphon', 'raven', 'cardinal', 'griffon', 'phoenix', 'roc', 'chimera', 'avian', 'albatross', 'cockatiel',
'dove', 'eagle', 'owl', 'penguin', 'cockatoo', 'shoebill', 'rito', 'crow', 'meadow[ -]?lark', 'torimimi',
'peacock', 'chocobo', 'emu', 'ostrich', 'flamingo', 'duck', 'swallow', 'nightingale', 'toucan',
'🦚', '🦃', '🦢', '🦆', '🦅', '🦉', '🦜', '🦩'],
[Species.Bat]: ['bat', 'nimbat', 'foxbat', 'pteropus', 'komorimimi', '🦇'],
[Species.Bovine]: ['cow', 'bison', 'bovine', 'antelope', 'gazelle', 'oryx', 'buffalo', 'bison', 'black[ -]?angus', 'bull', 'ox',
'ushimimi', 'holstaur', 'moo', 'ᴍᴏᴏ', 'cattle', 'hucow', 'caprin[a]?e', 'goat-antelope', 'muskox', 'urial', 'mouflon',
'🐃', '🐂', '🐄'],
[Species.Caprinae]: ['sheep', 'goat', 'ibex', 'takin', 'bharal', 'goral', 'serow', 'lamb', 'faun', 'ram', 'faunus', 'goat.*',
'yagimimi', 'hitsujimimi'],
[Species.Camielidae]: ['camel', 'llama', 'alpaca', 'guanaco', 'dromedary', 'dromedar', '🦙', '🐪', '🐫'],
[Species.Cervine]: ['deer', 'elk', 'moose', 'caribou', 'reindeer', 'doe', 'cervid', 'cervine', 'stag', 'shikamimi'],
[Species.Dinosaur]: ['raptor', 't-rex', 'death[ -]?claw', 'pterodactyl', '[\\w-]*saurus', 'dinosaur', 'trex', 'tyrannosaurus',
'saurian', '[\\w-]*raptor', 'deinonychus', 'dino',
'🦖', '🦕'],
[Species.Erinaceidae]: ['hedgehog', 'gymnure', 'moonrat'],
[Species.Elephantidae]: ['elephant', 'mammoth', 'mastodon', 'pachyderm', 'tusker'],
[Species.Fish]: ['shark', 'great white', 'sergal', 'fish', 'aquatic', 'melanopterus', 'carcharhinus', '.*fish', '.*shark'],
[Species.Giraffe]: ['giraffe', '🦒', 'kirinmimi'],
[Species.Hippopotamidae]: ['hippo', 'hippopotamus', '🦛'],
[Species.Hyaenidae]: ['hyena', 'aardwolf', 'hyaena', 'yeen'],
[Species.Hybrid]: ['hybrid', 'cabbit', 'fabbit', 'laquine', 'folf', 'myox', 'wolger', 'silkie', 'yumar',
'foxcoon', 'drazelle', 'vulpkanin', 'poochyena', 'batpon', 'delphox'],
[Species.Insect]: ['bug', 'bee', 'wasp', 'ant', 'spider', 'arachnid', 'scorpion', 'insect', 'buggo', 'hornet', 'vespidae',
'mantis', 'beefolk', 'ladybug', 'hachimimi', 'moth', 'bumblebee'],
[Species.Lapine]: ['bunny', 'rabbit', 'hare', 'lapine', 'viera', 'wabbit', 'lagomorph', 'bunny[ -]?(girl|bo[yi][e])', 'usagimimi',
'bun', '.*bunny', 'cabbit', 'fabbit', 'häschen', 'bunbun', 'cottontail', 'jack[ -]?rabbit', 'lapine?', 'jackalope', '🐇'],
[Species.MarineMammal]: ['whale', 'killer[ -]?whale', 'dolphin', 'orca', '🐬'],
[Species.Marsupial]: ['kangaroo', 'opossum', 'koala', 'wombat', 'possum', 'roo', 'bandicoot', 'bilby', 'numbat', 'wallaby',
'thylacine', 'marsupial[ -]?wolf', 'tasmanian[ -]?tiger', 'quokka', 'glider', 'cuscus', 'marsupial', 'tasmanian[ -]?devil', 'musky[ -]?rat',
'bettong', 'Känguru', '🦘', '🐨'],
[Species.Mephitidae]: ['skunk', 'stink[ -]?badger', '🦨'],
[Species.Herpestidae]: ['mongoose', 'meerkat', 'kusimanse', 'suricate'],
[Species.Musteline]: ['otter', 'ferret', 'mink', 'weasel', 'stoat', 'wolverine', 'marten', 'musteline', 'badger', 'otterkin',
'kawausomimi', 'itachimimi', 'ferettomimi', '🦡', '🦦'],
[Species.Pinniped]: ['seal', 'walrus', 'fur seal', 'sea[ -]?lion'],
[Species.Primate]: ['gorilla', 'monkey', 'ape', 'chimp', 'lemur', 'bonobo', 'chimpanzee', 'silverback', 'sarumimi', '🐒', '🦍', '🦧'],
[Species.Procyon]: ['raccoon', 'coatimund', 'longtail', 'procyon', 'tanuki', 'tanukimimi', '🦝', 'racoon', 'rakunmimi',
'ring[ -]?tail(ed)?'],
[Species.Rhinoceros]: ['rhino', 'rhinoceros', '🦏', '.*rhino'],
[Species.Rodent]: ['rat', 'mouse', 'chipmunk', 'squirrel', 'hamster', 'rodent', 'maus', 'gerbil', 'mousie', 'muskrat', 'ratsin',
'skaven', 'roedor', 'risumimi', 'nezumimi', 'jerboa', 'burmecian', '🐀', '🐁', '🐿'],
[Species.Suidae]: ['pig', 'boar', 'warthog', 'bushpig', 'babirusa', 'sow', 'swine', 'suid', 'suine', 'piglet', 'hog',
'piggie', 'piggy', 'quilboar', 'porcine', 'porcid', 'butamimi', '🐗', '🐖'],
[Species.Ursine]: ['bear', 'panda', 'grizzly', 'black[ -]?bear', 'brown[ -]?bear', 'polar[ -]?bear', 'ursine', 'pandaren', 'ursus',
'pandamimi', 'kumamimi'],
[Species.Demon]: ['demon', 'devil', 'succubus', 'incubus', 'daemon', 'deamon', 'demoness', 'demonkin', 'baphomet', 'eredar',
'tengu', 'devilkin', 'd[a]?emonette', 'cambion', 'amanojaku', 'tanar[\']?ri', 'balor', 'marilith', 'lilith'],
[Species.Divinity]: ['god', 'goddess', 'demi[ -]?god', 'demi[ -]?goddess'],
[Species.Fae]: ['fairy', 'fae', 'imp', 'elemental', 'fey', 'pixie', 'nymph', 'faerie'],
[Species.Humanoid]: ['satyr', 'gnome', 'dwarf', 'halfling', 't[h]?(ie|ei)fling', 'dwarves', 'humanoid', 'yordle', 'hylian', 'lalafell',
'zwerg'],
[Species.Minotaur]: ['minotaur', 'tauren'],
[Species.Bat]: ['bat'],
[Species.Alien]: ['alien', 'krogan', 'xenomorph'],
[Species.Mephitidae]: ['skunk'],
[Species.Robot]: ['android', 'robot', 'cyborg'],
[Species.Dinosaur]: ['saurus', 'deathclaw', 'dinosaur', 'raptor', 'trex', 't-rex'],
[Species.Pokemon]: ['charizard', 'charmander', 'pikachu', 'digimon', 'renamon', 'eevee', 'gardevoir', 'absol', 'aggron', 'jolteon', 'lopunny'],
[Species.Fae]: ['fairy', 'fae', 'imp', 'elemental'],
[Species.Taur]: ['chakat', 'centaur', 'equitaur'],
[Species.Vampire]: ['vampyre', 'vampire', 'dhampir', 'daywalker'],
[Species.Monster]: ['gnoll', 'goblin', 'kobold', 'monster', 'troll', 'illithid', 'golem', 'basilisk', 'oni', 'kaiju', 'mimic',
'hippogriff', 'hippogryph', 'manticore', 'harpy', 'gargoyle', 'ghost', 'eldritch', 'tentacle', 'youkai', 'ogre', 'skeleton',
'ghoul', 'vrykolakas', 'godzilla', 'bugbear', 'gnobold', 'undead', 'lich',
'gryphon', 'griffin', 'y[oō]kai', 'shinigami', 'bunyip'],
[Species.Naga]: ['naga', 'lamia'],
[Species.Monster]: ['gnoll', 'goblin', 'kobold', 'monster', 'troll', 'illithid', 'golem', 'basilisk'],
[Species.Giraffe]: ['giraffe'],
[Species.Rhinoceros]: ['rhino', 'rhinoceros']
[Species.Taur]: ['centaur', 'chakat', 'equitaur', 'felitaur', 'weretaur', 'humantaur', 'taur'],
[Species.Orc]: ['orc', 'uruk-hai', 'snaga', 'uruk[ -]?hai', 'ork'],
[Species.Vampire]: ['vampire', 'd[h]?amp[h]?ir', 'daywalker', 'vampyre', 'vampiric', 'vampir', 'nosferatu'],
[Species.Were]: ['werewolf', 'lycan', 'werelion', 'weretiger', 'werebear', 'werecoyote', 'werehog', 'were[ -]?wolf', 'were[ -]?lion',
'were[ -]?bear', 'were[ -]?coyote', 'were[ -]?hog', 'lycant[h]?rop[h]?e', 'loup[ -]?garou[sx]?',
'were[ -]?squirrel', 'were[ -]?donkey'],
[Species.Alien]: ['krogan', 'xenomorph', 'quarian', 'turian', 'asari', 'togruta', 'otolla', 'gungan', 'chiss', 'alien', 'puazi',
'hutt', 'klyntar', 'twi\'?lek', 'sangheili', 'salarian', 't[\']?vaoan'],
[Species.Robot]: ['android', 'cyborg', 'gynoid', 'automaton', 'robot', 'transformer', 'cybertronian', 'reploid', 'synth', 'ai'],
[Species.Hub]: ['hub', 'varies', 'various', 'variable', 'many', 'flexible', 'any', 'partner preference']
};
@ -262,3 +412,14 @@ export const kinkMapping: KinkPreferenceMap = {
no: KinkPreference.No
};
export interface SpeciesMappingCacheRecord {
regexp: RegExp;
keyword: string;
}
export interface SpeciesMappingCache {
[key: number]: SpeciesMappingCacheRecord[];
}

View File

@ -10,9 +10,9 @@ import {
Gender, genderKinkMapping,
Kink,
kinkMapping,
KinkPreference, mammalSpecies, nonAnthroSpecies,
KinkPreference, likelyHuman, mammalSpecies, nonAnthroSpecies,
Orientation,
Species, speciesMapping,
Species, SpeciesMap, speciesMapping, SpeciesMappingCache,
speciesNames,
SubDomRole,
TagId
@ -421,6 +421,7 @@ export class Matcher {
const speciesScore = Matcher.getKinkSpeciesPreference(you, theirSpecies);
if (speciesScore !== null) {
// console.log(this.them.name, speciesScore, theirSpecies);
const speciesName = speciesNames[theirSpecies] || `${Species[theirSpecies].toLowerCase()}s`;
return Matcher.formatKinkScore(speciesScore, speciesName);
@ -744,23 +745,50 @@ export class Matcher {
return Species.Human; // best guess
}
return Matcher.getMappedSpecies(mySpecies.string);
const s = Matcher.getMappedSpecies(mySpecies.string);
if (!s) {
console.log('Unknown species', c.name, mySpecies.string);
}
return s;
}
static getMappedSpecies(species: string): Species | null {
static generateSpeciesMappingCache(mapping: SpeciesMap): SpeciesMappingCache {
return _.mapValues(
mapping,
(keywords: string[]) => _.map(
keywords,
(keyword: string) => {
const keywordPlural = `${keyword}s`; // this is weak: elf -> elves doesn't occur
return {
keyword,
regexp: RegExp(`(^|\\b)(${keyword}|${keywordPlural})($|\\b)`)
};
}
)
);
}
private static speciesMappingCache?: SpeciesMappingCache;
private static likelyHumanCache?: SpeciesMappingCache;
private static matchMappedSpecies(species: string, mapping: SpeciesMappingCache): Species | null {
let foundSpeciesId: Species | null = null;
let match = '';
const finalSpecies = species.toLowerCase().trim();
_.each(
speciesMapping,
(keywords: string[], speciesId: string) => {
mapping,
(matchers, speciesId: string) => {
_.each(
keywords,
(k: string) => {
if ((k.length > match.length) && (finalSpecies.indexOf(k) >= 0)) {
match = k;
matchers,
(matcher) => {
// finalSpecies.indexOf(k) >= 0)
if ((matcher.keyword.length > match.length) && (matcher.regexp.test(finalSpecies))) {
match = matcher.keyword;
foundSpeciesId = parseInt(speciesId, 10);
}
}
@ -771,6 +799,19 @@ export class Matcher {
return foundSpeciesId;
}
static getMappedSpecies(species: string): Species | null {
if (!Matcher.speciesMappingCache) {
Matcher.speciesMappingCache = Matcher.generateSpeciesMappingCache(speciesMapping);
}
if (!Matcher.likelyHumanCache) {
Matcher.likelyHumanCache = Matcher.generateSpeciesMappingCache(likelyHuman);
}
return Matcher.matchMappedSpecies(species, Matcher.speciesMappingCache)
|| Matcher.matchMappedSpecies(species, Matcher.likelyHumanCache);
}
static getAllSpecies(c: Character): Species[] {
const species = Matcher.getAllSpeciesAsStr(c);
return _.filter(_.map(species, (s) => Matcher.getMappedSpecies(s)), (s) => (s !== null)) as Species[];
@ -783,7 +824,8 @@ export class Matcher {
return [];
}
const speciesStr = mySpecies.string.trim().toLowerCase().replace(/optionally|alternatively/g, ',').replace(/[)(]/g, '');
const speciesStr = mySpecies.string.toLowerCase().replace(/optionally|alternatively/g, ',')
.replace(/[)(]/g, ' ').trim();
const matches = speciesStr.split(/[,]? or |,/);
return _.filter(_.map(matches, (m) => m.toLowerCase().trim()), (m) => (m !== ''));