Feature - Implemented Improve/refactor internal Wiki lookup methods

Veracity

Developer
Staff member
In this thread, Cool12309 pointed out that the "checkplurals" command could not lookup all items on the Wiki. He made these observations:

These are all due to a few things:
  • &: The wiki seems to encode the & into &, so the matcher probably is checking & against & and finding them to be different.
  • ?: Same as above.
  • #: The wiki cannot have # in the title as # is used as an anchor, so the text before the # is the title that is hit when mafia sends a request. The actual title names on the wiki are the item names without the #.
  • '' and "": I believe the issue here is something to do with there being two of ' or ", as items with a single ' seem to work fine.
  • Skillbooks: Some skillbooks have the same item and skill (and effect) name, so the wiki makes the actual item/skill/effect name a disambig and makes the titles append (item), (skill), and (effect) to the end to differentiate. Easiest way to handle is probably to check if the item name has a corresponding skill name and if so, add " (item)" to the end when requesting the wiki's plural.
  • <i></i>: Probably another encoding issue.

Well, checkplurals uses a function in DebugDatabase:

Code:
	private static final String constructWikiName( String name )
	{
		name = StringUtilities.globalStringReplace( StringUtilities.getDisplayName( name ), " ", "_" );
		return Character.toUpperCase( name.charAt( 0 ) ) + name.substring( 1 );
	}
That's pretty simple minded.

I notice that ShowDescriptionList has a public method: getWikiLocation( Object item ) which handles disambiguating skills, effects, and skills. It also looks up the "Wiki Name" modifier for items that have weird characters that the Wiki treats specially. Looking at modifiers.txt, I see the following:

Code:
frigid hankyū	Cold Damage: +6, Moxie: +2, Wiki Name: "frigid hankyu"
TΤ◊lisman of Baiø‡	Wiki Name: "Bugged baio"
Bash-Ōs cereal	Wiki Name: "Bash-Os cereal"
Bash-Ōs boxtop	Wiki Name: "Bash-Os boxtop"
El Vibrato punchcard (ATTACK)	Wiki Name: "El Vibrato punchcard (115 holes)"
El Vibrato punchcard (BUFF)	Wiki Name: "El Vibrato punchcard (129 holes)"
El Vibrato punchcard (BUILD)	Wiki Name: "El Vibrato punchcard (165 holes)"
El Vibrato punchcard (DRONE)	Wiki Name: "El Vibrato punchcard (182 holes)"
El Vibrato punchcard (FLOOR)	Wiki Name: "El Vibrato punchcard (88 holes)"
El Vibrato punchcard (MODIFY)	Wiki Name: "El Vibrato punchcard (213 holes)"
El Vibrato punchcard (REPAIR)	Wiki Name: "El Vibrato punchcard (97 holes)"
El Vibrato punchcard (SELF)	Wiki Name: "El Vibrato punchcard (216 holes)"
El Vibrato punchcard (SPHERE)	Wiki Name: "El Vibrato punchcard (104 holes)"
El Vibrato punchcard (TARGET)	Wiki Name: "El Vibrato punchcard (142 holes)"
El Vibrato punchcard (WALL)	Wiki Name: "El Vibrato punchcard (176 holes)"
I have the following suggestions:

1) Add "Wiki Name" modifiers to all the other problematic items.
2) Refactor ShowDescriptionList.getWikiLocation( Object item ):
- Create WikiUtilities.getWikiLocation( String name, int type ), where "type" is ITEM_NAME, EFFECT_NAME or SKILL_NAME. This uses the last half of the original method, where it looks up the Wiki Name modifier, if needed, and disambiguates with (item), (effect) or (skill), as needed.
- The original method translates the Object into a name and a constant: ITEM_NAME, EFFECT_NAME, or SKILL_NAME and calls the method in WikiUtilities.
3) Get rid of the method in DebugDatabase and call the method in WikiUtilities.
 
Revision 15088 adds WikiUtilities and makes ShowDescriptionList and DebugDatabase use it.

I started running checkplurals and hit rollover, so it stopped. But before it stopped, it logged this:

Code:
*** Item #13: KoLmafia plural = "Items #13", Wiki plural = ""
*** 'Villa' document: KoLmafia plural = "'Villa' documents", Wiki plural = "'Villa' documents"
*** zmobie: KoLmafia plural = "zombeis", Wiki plural = ""
*** Cat-Herding Prod has bogus Wiki plural: "I Am A Fish". Ignoring.
*** black & tan: KoLmafia plural = "blacks & tans", Wiki plural = "blacks & tans"
Item #13 needs a Wiki Name
zmobie shows that we need to disambiguate on monster names, too. Huh.
The others are issues (or not) with checkplurals.

Well, I will run it again and attempt to identify everything that needs a Wiki Name modifier.
 
I have now run "checkplurals" not-logged-in - which makes it go to the Wiki every time. I found the following issues with successfully finding the Wiki page: (there were other issues with what we found there for successful lookups, but this Feature is about the URL translation, so if we find the right page, it is irrrelevant).

Code:
*** Bulky Buddy Box: KoLmafia plural = "Bulky Buddy Boxen", Wiki plural = ""
*** BRICKO octopus: KoLmafia plural = "BRICKO octopodes", Wiki plural = ""
These are most easily dealt with via a "Wiki Names" modifier.

Code:
*** elven limbos gingerbread: KoLmafia plural = "wafers of limbos gingerbread", Wiki plural = ""
*** Vial of jus de larmes: KoLmafia plural = "vials of jus de larmes", Wiki plural = ""
*** Lobster qua Grill: KoLmafia plural = "pieces of Lobster qua Grill", Wiki plural = ""
*** ectoplasm au jus: KoLmafia plural = "bottles of ectoplasm au jus", Wiki plural = ""
These are all things that are easily dealt with by removing italics markup. Yes, we could do it with a Wiki Name, but in case KoL introduces another one and the Wiki deals with it the same way, let's just strip out the italics.

Code:
*** water wings: KoLmafia plural = "sets of water wings", Wiki plural = ""
*** knuckle sandwich: KoLmafia plural = "knuckle sandwiches", Wiki plural = ""
*** industrial strength starch: KoLmafia plural = "boxes of industrial strength starch", Wiki plural = ""
These are all cases where the Wiki has no problem with the item, but KoLmafia thinks the item and an effect or skill is identical because they look the same ignoring capitalization. That's an issue with our Wiki lookup.

Code:
*** sweet tooth: KoLmafia plural = "sweet teeth", Wiki plural = ""
And what the heck is this? It looks like we can't find the Wiki page, but I don't know why.

Revision 15091 adds the Wiki Name modifiers and strips out italic markup when looking up Wiki names. The last four issues I mentioned remain.
 
Code:
*** sweet tooth: KoLmafia plural = "sweet teeth", Wiki plural = ""
And what the heck is this? It looks like we can't find the Wiki page, but I don't know why.

I haven't updated yet to grab any of the changes you just made for this. When I run "checkplurals 7481" (itemid for sweet tooth) it finds a match (there's no output for a discrepancy). My first guess is that the new code is looking up Sweet Tooth (an effect) instead of sweet tooth (the item).

Edit: Which I see now means it's in the same category as the block above it.
 
Last edited:
Ah. Very likely. In which case, that issue joins with the other 3 that are "item with one capitalization vs. effect of skill with another capitalization" issues.

The solution in all such cases is to see if the actual item (data) name is an exact match with the effect of the same (data) name, rather than comparing canonical names.

In recent years, I have gotten more and more unhappy with how much internal code deals with "canonical" (lowercased) names vs. the actual (data) name that KoL itself uses. I think "canonical" names are fine for dealing with user input - let the user not worry about case! - but when comparing internal data with KoL data, we should keep the case.

I have changed lots and lots of places to preserve case, and this is yet another example.
 
And another thing:

Bulky Buddy Box is a familiar hatchling - which goes to Bulky Buddy Box (hatchling) on the Wiki - or a familiar (same capitalization) - which goes to Bulky Buddy Box (familiar) on the Wiki.

I added a Wiki Name modifier which translates that name to the (hatchling) Wiki page. That's not right, if you actually want to look up the familiar.

I think I may have to hardcode the Wiki Lookup such that if you ask for an ITEM, you get the hatchling, and if you ask for the something else (especially if you want a FamiliarData), you get the familiar.

KoL names which are (case sensitive) identical for items/effects/familiars/whatever are a pain.
 
OK. Wiki lookup now works for those 4 items and also the Bulky Buddy Box.

Well, for the latter, if you ask for an ITEM, you get the hatching. On the Databse Frame, you can ask for a Wiki lookup as either an Item or a Familiar, and it sends you to the Disambiguation page, since that frame only has a "String" for the name, not a FamiliarData or an AdventureResult or something which would let it decide what it's looking for. I'm OK with that.

I declare this Feature to be done.
 
Does this potentially help the 'lookup' command know more about wiki names for familiars, skills, effects, locations, etc?
 
The "lookup" command looks up items and effects - no familiars, skills, locations, ...
It calls ShowDescriptionList.showWikiDescription() to do it, and that method uses the new WikiUtilities package, so, yes, that should work better.
 
Back
Top