asyml / forte

Forte is a flexible and powerful ML workflow builder. This is part of the CASL project: http://casl-project.ai/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Associate entry with `Payload`

mylibrar opened this issue · comments

Is your feature request related to a problem? Please describe.
Now that we can create multiple payloads, we should consider how to create new entry objects that are associated with a specific payload. We should also implement the Payload.get() method to retrieve entries from a specific Payload entry.

Describe the solution you'd like

  • Design how to associate an entry with Payload. Below is one tentative solution:

    # Create a Sentence annotation on text payload at index 2
    
    # Solution 1:
    pack.set_text_payload_index(2)
    Sentence(pack, begin, end)
    
    # Solution 2:
    sentence = Sentence(pack, begin, end)
    sentence.text_payload_index = 2
  • It should be compatible with the previous interfaces. When payload index is not specified, it should default to text payload at index 0.

  • Design how to retrieve entries from Payload. Below is a tentative interface design of Payload.get:

    image_payload = pack.get_payload_at(1) 
    text_payload = pack.get_payload_at(2) 
    audio_payload = pack.get_payload_at(3) 
    
    image_payload.get(Box) 
    text_payload.get(Sentence) 
    audio_payload.get(Recording) 
    
    # This should return an empty iterator 
    image_payload.get(Recording) 
  • Design the expected behavior of deleting a Payload entry

    • How to handle the entries associated with the deleted Payload?
    • Do we allow its payload index to be reused? For example, if we delete the payload at text_payload_list[3], can we reserve this position 3 for new text payload?

Describe alternatives you've considered
The design above is not final. We can discuss different solutions and their trade-offs.

Additional context
Include test cases to cover all common use cases.