🐐
This commit is contained in:
@@ -113,6 +113,7 @@ WIKIDATA_INSTANCE_TYPE_MAP = {
|
||||
"Q734698": CardType.artwork, # collectible card game
|
||||
"Q506240": CardType.artwork, # television film
|
||||
"Q738377": CardType.artwork, # student newspaper
|
||||
"Q2031291": CardType.artwork, # musical release
|
||||
"Q1259759": CardType.artwork, # miniseries
|
||||
"Q3305213": CardType.artwork, # painting
|
||||
"Q3177859": CardType.artwork, # dedicated deck card game
|
||||
@@ -121,6 +122,7 @@ WIKIDATA_INSTANCE_TYPE_MAP = {
|
||||
"Q1761818": CardType.artwork, # advertising campaign
|
||||
"Q1446621": CardType.artwork, # recital
|
||||
"Q1868552": CardType.artwork, # local newspaper
|
||||
"Q3244175": CardType.artwork, # tabletop game
|
||||
"Q63952888": CardType.artwork, # anime television series
|
||||
"Q47461344": CardType.artwork, # written work
|
||||
"Q71631512": CardType.artwork, # tabletop role-playing game supplement
|
||||
@@ -151,11 +153,14 @@ WIKIDATA_INSTANCE_TYPE_MAP = {
|
||||
"Q7930989": CardType.location, # city/town
|
||||
"Q1250464": CardType.location, # realm
|
||||
"Q3146899": CardType.location, # diocese of the catholic church
|
||||
"Q17350442": CardType.location, # venue
|
||||
"Q23764314": CardType.location, # sports location
|
||||
"Q12076836": CardType.location, # administrative territorial entity of a single country
|
||||
"Q35145263": CardType.location, # natural geographic object
|
||||
"Q15642541": CardType.location, # human-geographic territorial entity
|
||||
|
||||
"Q16521": CardType.life_form, # taxon
|
||||
"Q38829": CardType.life_form, # breed
|
||||
"Q310890": CardType.life_form, # monotypic taxon
|
||||
"Q23038290": CardType.life_form, # fossil taxon
|
||||
"Q12045585": CardType.life_form, # cattle breed
|
||||
@@ -183,6 +188,7 @@ WIKIDATA_INSTANCE_TYPE_MAP = {
|
||||
"Q15275719": CardType.event, # recurring event
|
||||
"Q27968055": CardType.event, # recurring event edition
|
||||
"Q15091377": CardType.event, # cycling race
|
||||
"Q87267404": CardType.event, # formula race
|
||||
"Q114609228": CardType.event, # recurring sporting event
|
||||
|
||||
"Q7278": CardType.group, # political party
|
||||
@@ -225,15 +231,23 @@ WIKIDATA_INSTANCE_TYPE_MAP = {
|
||||
"Q134808": CardType.science_thing, # vaccine
|
||||
"Q168845": CardType.science_thing, # star cluster
|
||||
"Q1491746": CardType.science_thing, # galaxy group
|
||||
"Q2465832": CardType.science_thing, # branch of science
|
||||
"Q1341811": CardType.science_thing, # astronomical maser
|
||||
"Q1840368": CardType.science_thing, # cloud type
|
||||
"Q2154519": CardType.science_thing, # astrophysical x-ray source
|
||||
"Q3132741": CardType.science_thing, # substellar object
|
||||
"Q15636229": CardType.science_thing, # surgery procedure
|
||||
"Q11862829": CardType.science_thing, # academic discipline
|
||||
"Q78088984": CardType.science_thing, # study type
|
||||
"Q17444909": CardType.science_thing, # astronomical object type
|
||||
"Q24034552": CardType.science_thing, # mathematical concept
|
||||
"Q12089225": CardType.science_thing, # mineral species
|
||||
"Q55640599": CardType.science_thing, # group of chemical entities
|
||||
"Q119459661": CardType.science_thing, # scientific activity
|
||||
"Q113145171": CardType.science_thing, # type of chemical entity
|
||||
|
||||
"Q1420": CardType.vehicle, # car
|
||||
"Q42889": CardType.vehicle, # vehicle
|
||||
"Q11446": CardType.vehicle, # ship
|
||||
"Q43193": CardType.vehicle, # truck
|
||||
"Q25956": CardType.vehicle, # space station
|
||||
@@ -252,12 +266,15 @@ WIKIDATA_INSTANCE_TYPE_MAP = {
|
||||
"Q928235": CardType.vehicle, # sloop-of-war
|
||||
"Q391022": CardType.vehicle, # research vessel
|
||||
"Q202527": CardType.vehicle, # minesweeper
|
||||
"Q1229765": CardType.vehicle, # watercraft
|
||||
"Q2031121": CardType.vehicle, # warship
|
||||
"Q1185562": CardType.vehicle, # light aircraft carrier
|
||||
"Q7233751": CardType.vehicle, # post ship
|
||||
"Q3231690": CardType.vehicle, # automobile model
|
||||
"Q1428357": CardType.vehicle, # submarine class
|
||||
"Q1499623": CardType.vehicle, # destroyer escort
|
||||
"Q4818021": CardType.vehicle, # attack submarine
|
||||
"Q15141321": CardType.vehicle, # train service
|
||||
"Q19832486": CardType.vehicle, # locomotive class
|
||||
"Q23866334": CardType.vehicle, # motorcycle model
|
||||
"Q29048322": CardType.vehicle, # vehicle model
|
||||
@@ -267,8 +284,12 @@ WIKIDATA_INSTANCE_TYPE_MAP = {
|
||||
"Q43229": CardType.organization, # organization
|
||||
"Q47913": CardType.organization, # intelligence agency
|
||||
"Q35535": CardType.organization, # police
|
||||
"Q740752": CardType.organization, # transport company
|
||||
"Q4830453": CardType.organization, # business
|
||||
"Q4671277": CardType.organization, # academic institution
|
||||
"Q2659904": CardType.organization, # government organization
|
||||
|
||||
"Q686822": CardType.other, # bill (written work)
|
||||
}
|
||||
|
||||
import asyncio
|
||||
@@ -399,9 +420,14 @@ async def _infer_card_type_async(client: httpx.AsyncClient, entity_id: str) -> t
|
||||
if superclass_qid2 in WIKIDATA_INSTANCE_TYPE_MAP:
|
||||
return WIKIDATA_INSTANCE_TYPE_MAP[superclass_qid2], superclass_qid2, language_count
|
||||
|
||||
# Fallback: coordinate location
|
||||
if "P625" in claims:
|
||||
return CardType.location, (qids[0] if qids else ""), language_count
|
||||
# Fallback: classify by presence of specific claims
|
||||
CLAIMS_FALLBACK = {
|
||||
"P625": CardType.location, # coordinate location
|
||||
"P437": CardType.artwork, # distribution format
|
||||
}
|
||||
for prop, fallback_type in CLAIMS_FALLBACK.items():
|
||||
if prop in claims:
|
||||
return fallback_type, (qids[0] if qids else ""), language_count
|
||||
|
||||
return CardType.other, (qids[0] if qids != [] else ""), language_count
|
||||
|
||||
@@ -525,7 +551,7 @@ async def _get_card_async(client: httpx.AsyncClient, page_title: str|None = None
|
||||
text=text,
|
||||
attack=attack,
|
||||
defense=defense,
|
||||
cost=min(11,max(1,int(((attack**2+defense**2)**0.18)/1.5)))
|
||||
cost=min(10,max(1,int(((attack**2+defense**2)**0.18)/1.5)))
|
||||
)
|
||||
|
||||
async def _get_cards_async(size: int) -> list[Card]:
|
||||
|
||||
Reference in New Issue
Block a user