Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associate entry with Payload #848

Open
mylibrar opened this issue Jul 1, 2022 · 0 comments
Open

Associate entry with Payload #848

mylibrar opened this issue Jul 1, 2022 · 0 comments

Comments

@mylibrar
Copy link
Collaborator

mylibrar commented Jul 1, 2022

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.

@mylibrar mylibrar added this to the 0.3 stable version milestone Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant