Avoid problem listing all US states with EntityList[]?

I wanted to do something (I thought) was simple. But my testing shows that listing the entities from a class of Administrative Division only works in certain specific cases.

The bug is that the 4th class of AdministrativeDivision always fails.

Also why there are 4 different classes for this makes one wonder.

Given this very simple initial example from the help for EntityList[]

EntityList[EntityClass["Country", "Countries"]] // Shallow

The obvious change…Something like this fails miserably

EntityList[EntityClass["AdministrativeDivision", "States"]]

So first check the known entity classes

EntityClassList["AdministrativeDivision"]

From just reading this list it looks like the following entries might work 4th, 5th, 13th and 85th. These are:

{EntityClassList["AdministrativeDivision"][[#]], 
   EntityClassList["AdministrativeDivision"][[#, 2]]} &@85

{EntityClassList["AdministrativeDivision"][[#]], 
   EntityClassList["AdministrativeDivision"][[#, 2]]} &@13

{EntityClassList["AdministrativeDivision"][[#]], 
   EntityClassList["AdministrativeDivision"][[#, 2]]} &@4

{EntityClassList["AdministrativeDivision"][[#]], 
   EntityClassList["AdministrativeDivision"][[#, 2]]} &@5

I have dumped these together with the internal name given that I have not found a consistent way to tell when the entity name (rendered in a pretty box in the front-end) will work with a function and when the internal name is required.Indeed this experiment shows that the entity name never works for these cases.

what is left is to replace each of these into the simple command above replacing "States".

In this case, none of the entities work and the internals work on each of these except the 4th class entry. The error message (Missing["UnknownEntityClass",) would lead you to believe that you supplied an invalid class. Of course that is misleading and should be improved (if possible).

The test cases can be run below.

EntityList[
 EntityClass["AdministrativeDivision", 
  EntityClassList["AdministrativeDivision"][[13]]]]

EntityList[
 EntityClass["AdministrativeDivision", 
  EntityClassList["AdministrativeDivision"][[13, 2]]]]

EntityList[
 EntityClass["AdministrativeDivision", 
  EntityClassList["AdministrativeDivision"][[4]]]]

EntityList[
 EntityClass["AdministrativeDivision", 
  EntityClassList["AdministrativeDivision"][[4, 2]]]]

EntityList[
 EntityClass["AdministrativeDivision", 
  EntityClassList["AdministrativeDivision"][[85]]]]

EntityList[
 EntityClass["AdministrativeDivision", 
  EntityClassList["AdministrativeDivision"][[85, 2]]]]

EntityList[
 EntityClass["AdministrativeDivision", 
  EntityClassList["AdministrativeDivision"][[5]]]]

EntityList[
 EntityClass["AdministrativeDivision", 
  EntityClassList["AdministrativeDivision"][[5, 2]]]]

EntityClass[“AdministrativeDivision”, “States”] is not a valid EntityClass. You can find a list of valid entity classes by running EntityClassList and InputForm to see the actual InputForms of the entities.

Is there a valid EntityClass given by EntityClassList that isn’t working for you?

There is no Interpreter for EntityClasses. I’m not sure that one would be helpful. They represent something kinda more arbitrary than Entities or EntityProperties. They’re just a list of what curated lists already exist and are rarely ever complete in some way, which you are unlikely to be able to guess without running EntityList.

Oh I see. At least one of the entities, EntityClass[“AdministrativeDivision”, “AllUSStatesAndTerritories”], isn’t working correctly right now.

Thank you for taking the time to let us know about the issue. The developers are looking into this problem so that it can be fixed.

Thank you Sean…and for explaining what an “Interpreter for EntityClass” means