2
$\begingroup$

Suppose I am looking for file formats associated with markup languages.

Lets say I would like to first find out about the ones which are web associated.

I look at the EntityClassList["FileFormat"] to find that they are in the class, EntityClass["FileFormat","Web"].

So I use the following query to find the markup language formats.

FilteredEntityClass[
    EntityClass["FileFormat","Web"],
    EntityFunction[c,
        StringMatchQ[c["Extension"],"*ml",IgnoreCase->True]||StringMatchQ[c["Name"],"*markup*",IgnoreCase->True]
    ]
]//EntityList

But I now also want the ones which are data associated like XML so would like to look in the class EntityClass["FileFormat","Data"] as well.

My question is what function f below will help me resolve this query.

FilteredEntityClass[
    f[EntityClass["FileFormat","Web"],EntityClass["FileFormat","Data"]],
    EntityFunction[c,
        StringMatchQ[c["Extension"],"*ml",IgnoreCase->True]||StringMatchQ[c["Name"],"*markup*",IgnoreCase->True]
    ]
]//EntityList

Basically f needs to Merge two EntityClass which have the same structure, i.e. Properties since they are both from the same parent class "FileFormat" into a new merged class and then the filter will be applied.

$\endgroup$
  • $\begingroup$ Have you looked at CombinedEntityClass? $\endgroup$ – kickert Jul 3 '19 at 12:01
  • $\begingroup$ I don't how to use CombinedEntityClass but it looks like it is used to perform SQL joins like, inner, outer - left & right and cross. But what I am looking here is what SQL calls UNION ALL operator. $\endgroup$ – user13892 Jul 3 '19 at 12:21
2
$\begingroup$

This represents an entity class of type "FileFormat" whose entities are members of one class or the other:

EntityClass["FileFormat", "EntityClasses" -> "Web" | "Data"]

And you can use it like you would any other entity class:

EntityList[
    FilteredEntityClass[
        EntityClass["FileFormat",
            "EntityClasses" -> "Web" | "Data"
        ],
        EntityFunction[c,
            Or[StringMatchQ[c @ "Extension", "*ml", IgnoreCase -> True],
                StringMatchQ[c @ "Name", "*markup*", IgnoreCase -> True]
            ]
        ]
    ]
] 
| improve this answer | |
$\endgroup$
0
$\begingroup$

It seems that simplest answer for your question is join the two EntityLists and then run all your calculations on that. Since the EntityProperties are the same, it shouldn't cause any issues.

Consider the following:

function = 
     EntityFunction[c, 
      StringMatchQ[c["Extension"], "*ml", IgnoreCase -> True] || 
       StringMatchQ[c["Name"], "*markup*", IgnoreCase -> True]]; web = 
     FilteredEntityClass[EntityClass["FileFormat", "Web"], function] // 
      EntityList;

data = FilteredEntityClass[EntityClass["FileFormat", "Data"], 
        function] // EntityList;

combined = Join[web, data];

results = DeleteMissing[
     EntityValue[combined, "EntityPropertyAssociation"], Infinity]

output

If you look at the InputForm of the EntityProperties, you will see they are all the same.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.