Card Tagging on mobile

User avatar
pokken
Posts: 6504
Joined: 4 years ago
Answers: 2
Pronoun: he / him

Post by pokken » 2 years ago

So I've been using the site on mobile a lot lately and I was wondering if there's a possibility of enabling some kind of auto-card-tagging, or a simplified UI for doing it on mobile.

Obviously complete autotagging would be challenging, but presumably we could simplify it by instead of using the entire ~25k card list we could shorten it to every card that's been used on the site and use some kinda set arithmetic to compare a set of words in the post to words in the cards to filter them to possibilities first before doing the detailed comparisons. I'd be happy to write a POC in Python if it would help.

I think ultimately autotagging would be the *best* since it'd apply everywhere, but alternatively if we came up with a cool UI for mobile that made it easier - especially in the quick reply window - I think that'd be decent too.

A button to suggest autotags and then approve them would be super cool too but I'm not sure how feasible that UI would be :)

User avatar
Feyd_Ruin
Elder Vampire
Posts: 5478
Joined: 5 years ago
Answers: 3
Pronoun: he / him
Contact:

Post by Feyd_Ruin » 2 years ago

For mobile, are you using the [ [ Cardname ] ] method?
It's much easier than trying to type [card]

As for auto autocarding every word. That would seem fairly intensive and end up carding words when you're not referring to a card name. Let me think on that
To the beaten, the broken, or the damned; the lost, and the wayward: wherever I may be, you will have a home.

User avatar
pokken
Posts: 6504
Joined: 4 years ago
Answers: 2
Pronoun: he / him

Post by pokken » 2 years ago

Feyd_Ruin wrote:
2 years ago
For mobile, are you using the [ [ Cardname ] ] method?
It's much easier than trying to type [card]

As for auto autocarding every word. That would seem fairly intensive and end up carding words when you're not referring to a card name. Let me think on that
It's two pokes to get to the square brackets on my mobile keyboard, so I mostly do not do it (since it winds up being 8 taps per card unless I wait and do it after). The fastest method for me is to use the full editor and select but the buttons are very small to hit the card button.

Auto-card-tagging is something I have seen done that's somewhat iffy but I believe we could come up with an algorithm that is both fast and accurate - happy to help with that. I can write a POC in Python for simple tagging but we could also try an ML model to try to identify un-grammatic uses of words that might indicate cards.

User avatar
pokken
Posts: 6504
Joined: 4 years ago
Answers: 2
Pronoun: he / him

Post by pokken » 2 years ago

Just to kind of sketch out how I would approach making a highly performant card tagger - and I am sure other people have already done this (although most of the implementations I have seen have tons of artifacts);

(and a lot of this is robbed from how @Rumpy5897 and I did the high performance update to our deck analysis program)

1. tokenize the post into a set of strings (basically each word is a member of a set) which eliminates duplicates.

2. Maintain a blown up dictionary of all the cards ever tagged on the site in the format of
"word" → ( "this card has words", "another card with words", "words are great", "words of wind" )
"card" → ( "this card has words", "another card with words," )
"are" → ("words are great")

etc. then do set arithmetic on the keys of the cards dictionary against the words in the list, so
set(words in deck) UNION set(dictionary keys)

3. Loop across the values of the intersected set of words (e.g. words that might match magic cards) and check for their presence in the string of the text. If it's there, tag each instance from last index to first.

This avoids having to either check every card or do some kind of weird 'create a massive list of lengths from 1 to n where n is the longest possible magic card.'

Again, that's just a first cut and could have flaws I'm not seeing. Probably need some kind of UTF-8 charset normalization or something but the magic card DBs all have friendly names now so probably not needed.

---------------------------------

There're probably some refinements you could do with Articles (a, the, an, etc.) to make their index item the word after them, so 'a red' or 'the blue' or whatever as well that'd make it much more performant.

User avatar
Feyd_Ruin
Elder Vampire
Posts: 5478
Joined: 5 years ago
Answers: 3
Pronoun: he / him
Contact:

Post by Feyd_Ruin » 2 years ago

Our current server can't run python, it'd have to be in php :(
To the beaten, the broken, or the damned; the lost, and the wayward: wherever I may be, you will have a home.

User avatar
cheonice
Death to Chronos.
Posts: 473
Joined: 4 years ago
Pronoun: he / him
Location: NRW / Germany

Post by cheonice » 2 years ago

The german https://www.mtg-forum.de/ uses a features that lets you tag all the cards in a post simultaneously. This would be a dream come true :D
But I got no idea, what they are using...

User avatar
pokken
Posts: 6504
Joined: 4 years ago
Answers: 2
Pronoun: he / him

Post by pokken » 2 years ago

Feyd_Ruin wrote:
2 years ago
Our current server can't run python, it'd have to be in php :(
PHP has set math functionality, (array_intersect is the function I believe) and you would use Map or Hash table for dictionary logic.

I think Map would be best offhand? Haven't used PHP since version 4 lol so I'm just reading documentation.

So you'd do something like make a map of card words → array of cards, then compute a set of the keys in the map and then use array_intersect to find out what words in the post might be cards, etc.

Post Reply Previous topicNext topic

Return to “Community”