AggregatedEntityClass[class,"prop"f]
表示含有属性为 prop 的单个实体的实体类别,它的值是对整个指定的实体类别应用函数 f 后所得的结果.
AggregatedEntityClass[class,{"prop1"f1,"prop2"f2,…}]
通过对 class 应用 fi 构建多个属性 propi.
AggregatedEntityClass[class,propspec,gprop]
根据属性 gprop 的值形成元素为 class 的组,然后生成一个实体类别,其中每个组都有一个对应的实体.
AggregatedEntityClass[class,propspec,"pname"f]
根据通过应用实体函数 f 获得的值形成组,并将所得属性命名为 pname.
AggregatedEntityClass[class,propspec,{gspec1,gspec2,…}]
形成由 gspeci 定义的值是不同的类组成的组.
AggregatedEntityClass
AggregatedEntityClass[class,"prop"f]
表示含有属性为 prop 的单个实体的实体类别,它的值是对整个指定的实体类别应用函数 f 后所得的结果.
AggregatedEntityClass[class,{"prop1"f1,"prop2"f2,…}]
通过对 class 应用 fi 构建多个属性 propi.
AggregatedEntityClass[class,propspec,gprop]
根据属性 gprop 的值形成元素为 class 的组,然后生成一个实体类别,其中每个组都有一个对应的实体.
AggregatedEntityClass[class,propspec,"pname"f]
根据通过应用实体函数 f 获得的值形成组,并将所得属性命名为 pname.
AggregatedEntityClass[class,propspec,{gspec1,gspec2,…}]
形成由 gspeci 定义的值是不同的类组成的组.
更多信息
- 在 AggregatedEntityClass[class,"prop"f] 中,函数 f 可以是 EntityFunction[…] 对象或被视为 EntityFunction[x,fun[x["prop"]]] 的函数 fun.
- 在 AggregatedEntityClass[class,propspec] 中,propspec 内的 EntityFunction 对象实际上被应用于一个属性的关联,它的值是 class 中实体值的列表.
- 如果没有出现第三个参数,则不会将出现在 AggregatedEntityClass 的第二个参数中的 EntityFunction 表达式应用于第一个参数中的单个实体,而是应用于整个第一个参数,如果有第三个参数,则应用于根据第三个参数分组获得的实体类.
- 出现在 AggregatedEntityClass 的第三个参数中的 EntityFunction 表达式被分别应用于第一个参数中的各个实体.
- 与 GroupBy 不一样,如果第三个参数是列表,AggregatedEntityClass[class,propspec,{prop1,prop2,…}] 不执行层级式分组;相反,它将创建一个由 EntityValue[class,{prop1,prop2,…}] 的不同值给出的多个实体组成的类.
- EntityProperties[AggregatedEntityClass[class,{"name1"->entityfunc1,"name2"->entityfunc2,…},{"prop1","prop2",…}]] 返回 {EntityProperty[agg,"name1"],EntityProperty[agg,"name2"],…,EntityProperty[agg,"prop1"],EntityProperty[agg,"prop2"],…},其中 agg 是整个 AggregatedEntityClass 表达式.
范例
打开所有单元 关闭所有单元基本范例 (3)
AggregatedEntityClass["Country", "TotalArea" -> EntityFunction[e, Total[e["Area"]]]]["TotalArea"]Total[EntityValue["Country", "Area"]]AggregatedEntityClass["Element", "AtomicMass" -> Mean, "Period"]["AtomicMass"]与关系数据库支持的实体一起使用时,双参数的 AggregatedEntityClass 相当于在 SELECT 语句中使用聚合函数:
EntityRegister[EntityStore[RelationalDatabase[FindFile["ExampleData/ecommerce-database.sqlite"]]]]AggregatedEntityClass["payments", "amount" -> Total]["amount"]按国家/地区计算最高信用额度(类似于 SQL 语言中的 GROUP BY 语句):
AggregatedEntityClass["customers", "creditLimit" -> Max, "country"][{"country", "creditLimit"}]范围 (4)
第三个参数可以是 EntityFunction:
AggregatedEntityClass["Country", "MeanArea" -> EntityFunction[e, Mean[e["Area"]]], "RoundedPopulation" -> EntityFunction[c, Round[c["Population"], 100000000]]][{"RoundedPopulation", "MeanArea"}]AggregatedEntityClass[["G7"], "AggregatedPopulation" -> EntityFunction[e, f[e[EntityProperty["Country", "Population"]]]]]["AggregatedPopulation"]AggregatedEntityClass[["G7"], "MeanPopulation" -> EntityFunction[e, Mean[e[EntityProperty["Country", "Population"]]]]]["MeanPopulation"]//NAggregatedEntityClass[["G7"], "PopulationChart" -> EntityFunction[e, PieChart[e[EntityProperty["Country", "Population"]]]]]["PopulationChart"]AggregatedEntityClass[EntityClass["Country", "Europe"], {"Area" -> Total, "Population" -> Total}][{"Population", "Area"}]按多面体是否具有手性及凹性进行分组,并计算各组中多面体的数量:
AggregatedEntityClass["Polyhedron", "Count" -> EntityFunction[e, Length[e]], {"Chiral", "Concave"}]["Count", "EntityAssociation"]属性和关系 (2)
AggregatedEntityClass 生成与组对应的实体:
EntityList[AggregatedEntityClass["Element", "AtomicNumber" -> Mean, "Period"]]从 AggregatedEntityClass 获取的单个实体实际上对应于隐式实体:
Entity["Food",
{
EntityProperty["Food", "FoodType"] -> ContainsExactly[{Entity["FoodType", "IceCream"]}], EntityProperty["Food", "AddedFoodTypes"] -> ContainsExactly[{}], EntityProperty["Food", "Flavor"] -> Entity["FoodFlavor", "Chocolate"]
}
]["RelativeTotalCaloriesContent"]AggregatedEntityClass[EntityClass["Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{Entity["FoodType", "IceCream"]}], EntityProperty["Food", "AddedFoodTypes"] -> ContainsExactly[{}], EntityProperty["Food", "Flavor"] -> Entity["FoodFlavor", "Chocolate"]}], "RelativeTotalCaloriesContent" -> Median @* DeleteMissing]["RelativeTotalCaloriesContent"]巧妙范例 (1)
按顶点数量和是否为凸面体对多面体进行分组,并指定 "collage" 属性:
polys = AggregatedEntityClass["Polyhedron", "collage" -> EntityFunction[e, ImageCollage[e["Image"]]], {"VertexCount", "Convex"}];按顶点数对各组进行排序,并在 Tabular 中显示拼图:
SortedEntityClass[polys, "VertexCount"][{"collage"}, "Tabular"]技术笔记
相关指南
-
▪
- 使用关系数据库中的信息 ▪
- 知识表示和访问 ▪
- 数据库连接
文本
Wolfram Research (2019),AggregatedEntityClass,Wolfram 语言函数,https://reference.wolfram.com/language/ref/AggregatedEntityClass.html.
CMS
Wolfram 语言. 2019. "AggregatedEntityClass." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/AggregatedEntityClass.html.
APA
Wolfram 语言. (2019). AggregatedEntityClass. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/AggregatedEntityClass.html 年
BibTeX
@misc{reference.wolfram_2026_aggregatedentityclass, author="Wolfram Research", title="{AggregatedEntityClass}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/AggregatedEntityClass.html}", note=[Accessed: 10-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_aggregatedentityclass, organization={Wolfram Research}, title={AggregatedEntityClass}, year={2019}, url={https://reference.wolfram.com/language/ref/AggregatedEntityClass.html}, note=[Accessed: 10-August-2026]}