ket fn: extract-category


extract-category:
    description:
        extract-category ket
        extract the "category" from the given ket
        categories are separated by ": "
        with the most general category on the left, and the most specific on the right
        for example |animal: mammal: dog>
        has the most general category "animal", then the category "mammal" and then finally the "value" dog
        categories can be considered a type for the object
        Eg, |word: house> says house is a type of word
        and |food: apple> says apple is a type of food
        and we can define operators with respect to them
        Eg, op |food: *> #=> ...
        will define "op" with respect to all objects of type\category "food".

    examples:
        -- if there is no category, then return the empty ket:
        -- NB: this is in contrast to the python version of the Semantic DB which would instead return |dog>
        extract-category |dog>
            |>

        -- remove the "value" from the ket:
        -- in other words, extract the category of the ket
        extract-category |animal: mammal: dog>
            |animal: mammal>

        -- remove the "value" from the ket, and then the most specific "category":
        extract-category extract-category |animal: mammal: dog>
            |animal>

        -- or using the powered-operator notation:
        extract-category^2 |animal: mammal: dog>
            |animal>

        -- an abstract example:
        extract-category |a: b: c: d: e: f>
            |a: b: c: d: e>

    see also:
        extract-value, extract-head, extract-tail
Home