scrom / Experiments

a NodeJS text adventure - deliberately coded badly to re-experience the pain of legacy code
http://mvta.herokuapp.com/
2 stars 0 forks source link

improve synonym handling to support partial matches #322

Closed scrom closed 8 years ago

scrom commented 9 years ago

I tried this once before and it tended to return the wrong results when retrieving similar objects that were in the same place - mostly because all calls to getObject expect either a single object or nothing back.

basically we're after a partial word match on an object name or any of its synonyms. It's easy enough to do.

there's an increased load because we want to perform an accurate match first and then fall back to this afterward.

when falling back, if we obtain multiple results, we need to say "which one". (however this is already a limitation - and may also need to be addressed for duplicate items in some way or creatures with matching names - and is hard to then specify which is meant - hence we usually just take the first.

scrom commented 8 years ago

Looking through the code we have whole word matches already supported. If player enters a word or multiple words, if they match the artefact description then it returns a match.

I'll enhance this to do the same with the synonym list too.

This still doesn't cover partial words

scrom commented 8 years ago

Having tried to take this a step further this afternoon, this is as far as I'm going to take it - any more and things start to break from shared works (e.g. coffee / coffee machine)

scrom commented 8 years ago

worse that being able to make a step improvement, any further work on syns causes other conflicts. The only way to resolve this is to retrieve all objects matching supplied synonym and prioritise them based on what the match was. ugh