Message Boards Message Boards

1
|
1965 Views
|
4 Replies
|
5 Total Likes
View groups...
Share
Share this post:

The difference between A[" "] and EntityValue[A," "] in Real World Data?

Posted 1 year ago

Hello, I once thought A[" "] equals to the EntityValue[A," "] in Real World Data in MMA, but I am wrong. As in the case below:

Entity["GeographicRegion", "Europe"]["Countries"]["Flag"]

I get countries' names.

But in

EntityValue[Entity["GeographicRegion", "Europe"]["Countries"], "Flag"]

I will get countries' flags.

So what is the different between A[" "] and EntityValue[A," "] in Real World Data?

POSTED BY: Zhenyu Zeng
4 Replies
Posted 1 year ago
  1. No particular reason. I was just showing you an alternative.

  2. I already explained that. But I'll try again....

Start with

Entity["GeographicRegion", "Europe"]["Countries"]["Flag"]

We first evaluate

Entity["GeographicRegion", "Europe"]

which just returns the same expression, because it's just an "object" that represents a particular semantic. That particular "object" can be applied to an argument, and in this case it is so applied, so we next evaluate

Entity["GeographicRegion", "Europe"]["Countries"]

which gives {[Entity["Country", "Albania"], ..., Entity["Country", "VaticanCity"]}. Presumably you expected this.

But there is another step remaining in computing the expression. We apply the result we have so far to "Flag".

ExpressionWeHaveSoFar["Flag"]

The ExpressionWeHaveSoFar is {[Entity["Country", "Albania"], ..., Entity["Country", "VaticanCity"]}. so we really have

{[Entity["Country", "Albania"], ..., Entity["Country", "VaticanCity"]}["Flag"]

At this point there is nothing to do. We don't have any rule for evaluating this. So, that's the end of the computation.

POSTED BY: Eric Rimbey
Posted 1 year ago

Thanks for your patient explanation. I know how it works after reading it.

POSTED BY: Zhenyu Zeng
Posted 1 year ago

I get countries' names

No you don't. You get an expression that has a list of country names applied to the argument "Flag". Such an expression has no rewrite rule, so it remains unevaluated.

You could try this alternate:

EntityClass["Country", "Europe"]["Flag"]
POSTED BY: Eric Rimbey
Posted 1 year ago

Hello,

  1. Why should I use EntityClass here?
  2. why

    EntityValue[Entity["Country", "France"], "Flag"]
    

equals to

Entity["Country", "France"]["Flag"] 

but

Entity["GeographicRegion", "Europe"]["Countries"]["Flag"]

doesn't equal to

EntityValue[Entity["GeographicRegion", "Europe"]["Countries"], "Flag"]
POSTED BY: Zhenyu Zeng
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