Failing to programmatically modify a structure

Issue #709 resolved
fredericg created an issue

I'm trying to modify a newly created structure over a vocabulary. I'm just trying to set the domain of types, and setting predicates to true.

Is there any place where I can find more information about interfacing with IDP structures from lua procedures (tried manual, tutorial, ...)? I know that I'll probably need the maketrue(), ... functions, but how to index the structure, ...?

A sample use case can be found in attachment.

Comments (4)

  1. Bart Bogaerts
    • always quote strings, otherwise lua thinks they are variables (Jan)

    • You should not use .pred on things that cannot be types (Aankoop)

    • Be careful with types: you were trying to add "Jan, 500, while 500 was not in Bedrag

    • There are two possibilities:

    local struc = newstructure(voc, "test")
    struc[voc::Klant.type] = {"Jan"}
    struc[voc::Bedrag.type] = {500}
    maketrue(struc[voc::Aankoop], {"Jan", 500})
    print(struc)
    

    or

    local struc = newstructure(voc, "test")
    struc[voc::Klant.type] = {"Jan"}
    struc[voc::Bedrag.type] = {500}
    struc[voc::Aankoop].ct = {{"Jan", 500}}
    print(struc)
    
  2. fredericg reporter

    I know this probably isn't the place to ask such questions, but thank you for the solution :)

  3. fredericg reporter

    How about interpretating functions?

    Suppose I have the following voc:

    type Klant
    type Bedrag isa int
    type Type constructed from {A, B}
    Aankoop(Klant, Bedrag)
    Type(Klant):Type
    

    How can I then interprate the Type(Klant):Type function?

    local struc = newstructure(voc, "test")
    struc[voc::Klant.type] = {"Jan"}
    struc[voc::Bedrag.type] = {500}
    maketrue(struc[voc::Aankoop], {"Jan", 500})
    
    //maketrue(struc[voc::Type.func].graph, {"Jan", A})
    struc[voc::Type.func].graph.ct = {{"Jan", "A"}}
    print(struc)
    

    Nevermind, this seems to work..

  4. Log in to comment