Message Boards Message Boards

Workarounds for network timeouts when trying to use Interpreter["Person"]

I frequently get network timeout problems when using Interpreter in ways that require connectivity to the Wolfram server. My network connection in general is quite fast, so I don't think that's the issue. Here's an example.

We have a list of presidents using their common names.

 presidents=  {"George Washington", "John Adams", "Thomas Jefferson", "James \
 Madison", "James Monroe", "John Quincy Adams", "Andrew Jackson", \
 "Martin Van Buren", "William Henry Harrison", "John Tyler", "James K. \
 Polk", "Zachary Taylor", "Millard Fillmore", "Franklin Pierce", \
 "James Buchanan", "Abraham Lincoln", "Andrew Johnson", "Ulysses S. \
 Grant", "Rutherford B. Hayes", "James A. Garfield", "Chester A. \
 Arthur", "Grover Cleveland", "Benjamin Harrison", "Grover Cleveland \
 (2nd term)", "William McKinley", "Theodore Roosevelt", "William \
 Howard Taft", "Woodrow Wilson", "Warren G. Harding", "Calvin \
 Coolidge", "Herbert Hoover", "Franklin D. Roosevelt", "Harry S. \
 Truman", "Dwight D. Eisenhower", "John F. Kennedy", "Lyndon B. \
 Johnson", "Richard Nixon", "Gerald Ford", "Jimmy Carter", "Ronald \
 Reagan", "George H. W. Bush", "Bill Clinton", "George W. Bush", \
 "Barack Obama", "Donald Trump"};

I now want to represent them as entities so that users can get further information on them. So, here's the plan. I want to make one call to Interpreter rather than Map Interpreter over a list of names.

 presidentEntities=Interpreter["Person", True &, Missing[], AmbiguityFunction -> First][
   presidentNames]]

When I do this, I frequently get a network timeout error. Now it's Sunday afternoon here in the US and I wouldn't think this was peak load time. Moreover, I've gotten the error -- and similar errors for other Interpreter calls -- on many other occasions. Moreover, I don't think 45 names should really tax the Wolfram server too hard.

So, are there any user workarounds for this? (I've tried the ugly method of breaking up the list into pieces and then reassembling, but even that sometimes fails). Am I doing something wrong? Is there a way of making some Interpreter code local? Is there some way of determining that the Wolfram Server is having a bad day or hour or suffering a particularly heavy load?

More generally, is there something that can be done about WolframAlpha throughput. The Wolfram Language (as opposed to Mathematica) depends on access to vast amount of external data. But if I can't count on reliable service, it discourages use of programs and constructs that depend on that data and the Entity construct.

POSTED BY: Seth Chandler
2 Replies

I would avoid using:

AmbiguityFunction -> First

When you do that, you're essentially asking Wolfram|Alpha to provide a complete list of all possible people that name. The "First" is then ran later, so it's a bit of a waste. The default value of the option, Automatic, gives you the most likely interpretation.

Also, AmbiguityFunction is just a very confusing option overall. "First" doesn't really give you the first value from the AmbiguityList. You really have to use a ReplaceAll and some pattern matching to work with them as some of the documentation examples show. It's unintuitive.

I did a bit of digging. I would expect that both

Interpreter["Person"]

and

Interpreter["Person", True &, Missing]

Would do the same query to Wolfram|Alpha. And they do. After all, the second one really just says what to do with failing interpretations. One interesting thing is that this query might request the PersonData paclet the first time it's called, which would make it take longer. Subsequent evaluations don't seem to call Wolfram|Alpha because the data is cached.

I could imagine that it might make sense to preload PersonData by calling it in some cases, but I don't think that's actually really helpful to you. I don't know of a workaround really. We could write some code to locally try to associate a String to one of the president entities. For a case of this size, I think that's feasible.

POSTED BY: Sean Clarke

So, I just ran it again and found that the code worked quite fast. The problem is thus something funky in the Internet or variable loads on the Wolfram servers. I wonder if it would be possible for Wolfram to post a load meter that people could look at so they could get a sense of how hits on their servers are going to fare. Or maybe a load heat map showing how load varies by day of week and time. That way, longish queries might be a ScheduledTask to be run later. Or maybe a WolframServerLoad function?

POSTED BY: Seth Chandler
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract