CombinedEntityClass[class1,class2,prop]
表示通过将 class1 和 class2 中属性 prop 的值相同的两个实体的属性组合在一起而获得的一类实体.
CombinedEntityClass[class1,class2,prop1prop2]
组合 class1 和 class2 中的实体对,将 class1 中 prop1 的值与 class2 中 prop2 的值相同的实体组合在一起.
CombinedEntityClass[class1,class2,{pspeca,pspecb,…}]
将所有属性指定 pspeck 都相同的实体对组合在一起.
CombinedEntityClass[class1,class2,f]
将应用实体函数 f 所得值为 True 的实体对组合在一起.
CombinedEntityClass[class1,class2,spec,"jspec"]
通过 "jspec" 确定何种情况下允许将有缺失属性的实体也包含进来.
CombinedEntityClass
CombinedEntityClass[class1,class2,prop]
表示通过将 class1 和 class2 中属性 prop 的值相同的两个实体的属性组合在一起而获得的一类实体.
CombinedEntityClass[class1,class2,prop1prop2]
组合 class1 和 class2 中的实体对,将 class1 中 prop1 的值与 class2 中 prop2 的值相同的实体组合在一起.
CombinedEntityClass[class1,class2,{pspeca,pspecb,…}]
将所有属性指定 pspeck 都相同的实体对组合在一起.
CombinedEntityClass[class1,class2,f]
将应用实体函数 f 所得值为 True 的实体对组合在一起.
CombinedEntityClass[class1,class2,spec,"jspec"]
通过 "jspec" 确定何种情况下允许将有缺失属性的实体也包含进来.
更多信息
- EntityProperties[CombinedEntityClass[class1,class2,…]] 实际上就是 Join[EntityProperties[class1],EntityProperties[class2]].
- 在 CombinedEntityClass[class1,class2,f] 中,函数 f 的形式必须是 EntityFunction[{e1,e2},…],其中 e1 和 e2 分别表示 class1 和 class2 中的实体.
- CombinedEntityClass[class1,class2,…] 的结果中的属性的形式为 EntityProperty[typei,…],其中 typei 为 classi 的实体类型.
- CombinedEntityClass["alias1"->class1,"alias2"->class2,…] 可用来给出形式为 EntityProperty["aliasi"->typei,…] 的属性.
- 在 CombinedEntityClass[class1,class2,…] 中,classi 必须互不相同. 可将 CombinedEntityClass[class,"alias"->class] 用于相同的类.
- 在 CombinedEntityClass[ca,cb,spec,"jspec"] 中,组合指定 (join specification) jspec 确定对于来自类别 ca 的实体 ai 和来自类别 cb 的实体 bj 应保留哪些,这将取决于是否满足由 cond 定义的条件. 可能的与组合指定 JoinAcross 相同:
-
"Inner" 只保留满足条件的 ai、bj(默认) "Left" 保留没有与之相匹配的 bj 的 ai "Right" 保留没有与之相匹配的 aj 的 bi "Outer" 保留没有匹配的 ai 和 bj - 属性值不存在时,用 Missing["Unmatched"] 代替.
- CombinedEntityClass[class1,class2,EntityFunction[{x,y},True]] 实际上执行的是 SQL CROSS JOIN. 大约等价于将 Outer[Join,…] 应用于从两个类获取的 "PropertyAssociation".
范例
打开所有单元 关闭所有单元基本范例 (6)
将第 1 周期中的元素与其同位素组合起来,并比较它们的原子质量:
CombinedEntityClass["Isotope", EntityClass["Element", "Period1"], "Element" -> "Entity"][{EntityProperty["Isotope", "Name"], EntityProperty["Element", "AtomicMass"], EntityProperty["Isotope", "AtomicMass"]}]CombinedEntityClass 具有两个类的所有属性:
EntityProperties[CombinedEntityClass["Country", "City", "CapitalCity" -> "Entity"]] === Union[EntityProperties["Country"], EntityProperties["City"]]CombinedEntityClass["Isotope", EntityClass["Element", "Period1"], EntityFunction[{i, e}, i["AtomicMass"] < e["AtomicMass"]]][{EntityProperty["Isotope", "Name"], EntityProperty["Element", "Name"]}]CombinedEntityClass[FilteredEntityClass["Isotope", EntityFunction[i, i["Element"] == Entity["Element", "Hydrogen"] || i["Element"] == Entity["Element", "Lithium"]]], EntityClass["Element", "Period1"], "Element" -> "Entity", "Inner"][{EntityProperty["Isotope", "Name"], EntityProperty["Element", "Name"]}]CombinedEntityClass[FilteredEntityClass["Isotope", EntityFunction[i, i["Element"] == Entity["Element", "Hydrogen"] || i["Element"] == Entity["Element", "Lithium"]]], EntityClass["Element", "Period1"], "Element" -> "Entity", "Left"][{EntityProperty["Isotope", "Name"], EntityProperty["Element", "Name"]}]CombinedEntityClass[FilteredEntityClass["Isotope", EntityFunction[i, i["Element"] == Entity["Element", "Hydrogen"] || i["Element"] == Entity["Element", "Lithium"]]], EntityClass["Element", "Period1"], "Element" -> "Entity", "Right"][{EntityProperty["Isotope", "Name"], EntityProperty["Element", "Name"]}]CombinedEntityClass[FilteredEntityClass["Isotope", EntityFunction[i, i["Element"] == Entity["Element", "Hydrogen"] || i["Element"] == Entity["Element", "Lithium"]]], EntityClass["Element", "Period1"], "Element" -> "Entity", "Outer"][{EntityProperty["Isotope", "Name"], EntityProperty["Element", "Name"]}]CombinedEntityClass["Cloud", "other" -> "Cloud", "CloudType"][{EntityProperty["Cloud", "Name"], EntityProperty["other" -> "Cloud", "Name"]}]//Shallow与关系数据库支持的实体一起使用时,CombinedEntityClass 实际上等价于 JOIN 语句:
EntityRegister[EntityStore[RelationalDatabase[FindFile["ExampleData/ecommerce-database.sqlite"]]]]CombinedEntityClass["customers", "payments", "customerNumber"][{"customerName", "amount"}]//Shallow范围 (3)
定义新的 CombinedEntityClass:
combined = CombinedEntityClass["Isotope", "Element", "Element" -> "Entity"];filtered = FilteredEntityClass[combined, EntityFunction[e, e[EntityProperty["Element", "Group"]] == 17]];DeleteMissing[EntityValue[filtered, {EntityProperty["Isotope", "Name"], EntityProperty["Isotope", "DiagnosticApplications"]}], 1, 2]注册一个 EntityStore:
EntityRegister[EntityStore[Association["Types" -> Association[
"book" -> Association["Entities" -> Association["BU1032" ->
Association["book_author" -> EntityClass["book_author", {"title_id" -> "BU1032"}],
"title" -> "The Busy Executive's ... ity["author", "472-27-2349"]],
"25" -> Association["book" -> Entity["book", "TC4203"], "author" ->
Entity["author", "648-92-1872"]]], "Properties" -> Association["book" -> Association[],
"author" -> Association[]]]]]]]构建一个 CombinedEntityClass:
combined = CombinedEntityClass[CombinedEntityClass["book_author", "book", "book" -> "Entity"], "author", "author" -> "Entity"]EntityProperties[combined]EntityList[combined]EntityList@CombinedEntityClass["Book", "MusicWork", {"Name", "FirstPublished" -> "FirstReleaseDate"}]技术笔记
相关指南
-
▪
- 使用关系数据库中的信息 ▪
- 知识表示和访问 ▪
- 实体类型
文本
Wolfram Research (2019),CombinedEntityClass,Wolfram 语言函数,https://reference.wolfram.com/language/ref/CombinedEntityClass.html.
CMS
Wolfram 语言. 2019. "CombinedEntityClass." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/CombinedEntityClass.html.
APA
Wolfram 语言. (2019). CombinedEntityClass. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/CombinedEntityClass.html 年
BibTeX
@misc{reference.wolfram_2026_combinedentityclass, author="Wolfram Research", title="{CombinedEntityClass}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/CombinedEntityClass.html}", note=[Accessed: 13-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_combinedentityclass, organization={Wolfram Research}, title={CombinedEntityClass}, year={2019}, url={https://reference.wolfram.com/language/ref/CombinedEntityClass.html}, note=[Accessed: 13-September-2026]}