asyml / asyml/forte

Associate entry with `Payload`

Open
#848 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
253
Forks
59
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Payload and entry APIs, including get_payload_at, Sentence, Box, and Recording. Define the association, default payload behavior, Payload.get retrieval cases, and deletion or index-reuse behavior before adding tests for the common use cases requested in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.