Wolfram 语言

外部服务

比较两个城市对素食者的友好程度

连接到 Factual API 来获取有关位置的信息.

In[1]:=
Click for copyable input
factual = ServiceConnect["Factual"]
Out[1]=

寻找两个城市中素食主义者和素食的位置.

In[2]:=
Click for copyable input
resultsSeattle = factual["PlacesDataset", "Locality" -> Entity["City", {"Seattle", "Washington", "UnitedStates"}], "Query" -> "Vegan and vegetarian food", MaxItems -> 300]; resultsHonolulu = factual["PlacesDataset", "Locality" -> Entity["City", {"Honolulu", "Hawaii", "UnitedStates"}], "Query" -> "Vegan and vegetarian food", MaxItems -> 300];

获取位置的数目和密度.

显示完整的 Wolfram 语言输入
In[3]:=
Click for copyable input
TextGrid[{{"City", "Area", "Number of locations", "Density"}, {Entity[ "City", {"Seattle", "Washington", "UnitedStates"}], Entity["City", {"Seattle", "Washington", "UnitedStates"}]["Area"], Length[resultsSeattle], Length[resultsSeattle]/ Entity["City", {"Seattle", "Washington", "UnitedStates"}][ "Area"]}, {Entity[ "City", {"Honolulu", "Hawaii", "UnitedStates"}], Entity["City", {"Honolulu", "Hawaii", "UnitedStates"}]["Area"], Length[resultsHonolulu], Length[resultsHonolulu]/ Entity["City", {"Honolulu", "Hawaii", "UnitedStates"}]["Area"]}}, Frame -> All]
Out[3]=

相关范例

de en es fr ja ko pt-br ru