aws-samples / aws-samples/amazon-comprehend-semi-structured-documents-annotation-tools

Trouble trimming spans of text

Open
#29 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
24
Forks
15
PR merge metrics
No merged PRs in 30d

Description

I have some documents with some relatively narrow columns/chunks of text, and relatively long entities: For example an inline address. As a result it's quite common that I want to highlight an entity that crosses over multiple lines, but need to trim words off the beginning and end - can't just select the whole rectangle-shaped region as it would include unwanted words.

...But when using the slider (in Firefox ESR) to trim words, I'm getting caught with an instantaneous loop of word removals.

For example in the following sentence:

```
short words get lost without intending it when sliding
```

The length of each word here is: `[5, 5, 3, 4, 7, 9, 2, 4, 7]`

If I trim from the beginning, as soon as I slide character offset past 5, the word `short` gets dropped ***but*** straight away so do all following shorter words (`words get lost`) until a longer word is encountered. The system goes straight to trimming the first 5 characters out of this longer word (i.e. I have `ut indending it when sliding`). I can move the slider back to 0 to recover the start of this long word (`without intending it when sliding`) - but it's impossible for me to select starting from some shorter word in the middle - for example if I wanted `lost without intending it when sliding`.

I see the same thing when trimming from the end too: I.e. as soon as I remove 7 characters from the end, the UI drops not just the word `sliding` but everything until a longer word is encountered: `short words get lost without in`. I can select `short words get lost without intending`, but it's not possible to select e.g. `short words get lost without intending it`.

Basically whatever JS that's dropping words when we trim the span, is immediately looping through multiple words without giving us a chance to prevent it. So it is just not possible to highlight the above sentence (with the rectangular box) but then trim out long words and leave shorter words in e.g. to get to `lost without intending it`).

Contributor guide

Open the contributing guide

Research direction

No file or test is named. Reproduce the span-trimming behavior in Firefox ESR with the sentence and word lengths from the report, then locate the JavaScript that removes boundary words. Done means trimming removes only the intended boundary text and permits selections such as “lost without intending it when sliding” and “short words get lost without intending it”.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.