Message Boards Message Boards

0
|
4309 Views
|
6 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Search an entity list?

I'm using the Wolfram General Topology EntityStore. From it, how would I search EntityList["GeneralTopologyTheorem"] to find, for example, those entities in the list that include the word "compact" in their name.

Here's where I am:

    obj = ResourceObject["General Topology EntityStore"];
    store = ResourceData[obj];
    data = EntityRegister[store]
(* {"GeneralTopologyConcept", "GeneralTopologyTheorem"} *)
    thms = EntityList["GeneralTopologyTheorem"]

The output from the last statement is a list of entites which display as "boxes" labeled with such things as "metric implies Hausdorff".

How do I search the list to find, say, which of those theorems in the store concern being compactt?

My notion is to somehow convert all the labels on those boxes into text and search the list of such texts. But how do I make that conversion? Or is there some better way?

POSTED BY: Murray Eisenberg
6 Replies
Posted 4 years ago

Hi Murray,

Presumably, you are not just interested in filtering just the names, but would also like to access other properties from the filtered list of names. Here is a way to do that.

Create a FilteredEntityClass that contains the entities whose name contains "compact".

compactTheorems = FilteredEntityClass["GeneralTopologyTheorem",
   EntityFunction[n, StringContainsQ[n["CanonicalName"], "Compact", IgnoreCase -> True]]];

Make a Dataset with name and some property

compactTheorems // EntityList // 
  Map[<|#["CanonicalName"] -> CanonicalName@#["RelatedConcepts"]|> &] // 
  Dataset

enter image description here

Add a "DisplayName" property using ExtendedEntityClass

extendedCompactTheorems = ExtendedEntityClass[compactTheorems,
   {"DisplayName" -> EntityFunction[n, 
      StringRiffle[StringSplit[n["CanonicalName"], RegularExpression["(?=[A-Z])"]]]]}];

extendedCompactTheorems // EntityList // 
  Map[<|#["DisplayName"] -> #["AlternateNames"]|> &] //
  Dataset

enter image description here

POSTED BY: Rohit Namjoshi

That last reply (with extendedCompactTheorems) is very helpful, since I'm still crawling around on the ground when dealing with entities and datasets and not yet beginning to stand up.

POSTED BY: Murray Eisenberg

Yes, that StringSplit with a RegularExpression expression does precisely what I need. (Even if it leaves prepositions and conjunctions upper-cased, contrary to usual rules for titles.) Thank you!

(One of these days I'll once again try to learn regular expressions. Each time I begin I'm distracted by other work.)

POSTED BY: Murray Eisenberg
Posted 4 years ago

Hi Murray,

Is this what you are looking for?

EntityList["GeneralTopologyTheorem"] // CanonicalName //
  Select[StringContainsQ[#, "compact", IgnoreCase -> True] &]
POSTED BY: Rohit Namjoshi

Yes, that Select together with CanonicalName did it. (The missing ingredient for me was CanonicalName.)

Now I have to figure out how to make the CamelCased entries in the output, e.g., change "CompactSubspaceOfHausdorffSpaceIsClosed" to "Compact Subspace Of Hausdorff Space Is Closed", so as to make the output more readable.

POSTED BY: Murray Eisenberg
Posted 4 years ago

Here is one way

StringSplit["CompactSubspaceOfHausdorffSpaceIsClosed", RegularExpression["(?=[A-Z])"]] //
  StringRiffle

(* "Compact Subspace Of Hausdorff Space Is Closed" *)
POSTED BY: Rohit Namjoshi
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