I'm looking for a word/sentence annotation tool/plugin to be used INSIDE vim editor. Specifically I'm looking for a cli tool NER (named entity) tagging. Any idea/suggestion/tip?
By example, I would like to select a word or a list of contiguous words (using all vim conveniences) associating them to a a tag/label, say from a menu of tags (read form a config file, TBD).
The tagged text would be coloured with a nice background color and the file would be saved in a desired (configurable format). By example I would tag each NER span with a format like
[entity text span literal](entity_name)
By example, suppose I edit in vim a .txt or .yaml format (input) like this:
Original file (without tagging)
- intent: body_temperature_data
examples: |
- il termometro misura 36.3 gradi
- 36.9
- 35.9
- 35,9
- la temperatura è di 36 e 7 gradi
- 36 , 8
Tagged file: desired output file
I want to tag some numbers are entity body_temperature
, saving the file (in output) like this:
- intent: body_temperature_data
examples: |
- il termometro misura [36.3](body_temperature) gradi
- [36.9](body_temperature)
- [35.9](body_temperature) gradi
- temperatura: [35,9](body_temperature)
- la temperatura è di [36 e 7](body_temperature) gradi
- [36 , 8](body_temperature)
Tagged file: visualization in NORMAL mode
Visually, during editing inside vim, I would like to see tagged words (numbers in the example) visualized with a background color (changing for each (preselected from a menu) label).
Example of visualization with web-based interface:
See visualization examples:
I guess one could realize al this coding a plugin in vimscript.
I have in mind a similar example, the plugin https://github.com/elzr/vim-json to escape double quotes in editing JSON. In that case when you are editing the current line, double quotes are visible, otherwise aren't. In analogy:
- when in INSERT mode I would like to edit full text LINE
- whereas, when in NORMAL mode I would like to tag with the above mentioned experience (selecting& tag). By example: the cursor is INSIDE a word or I selected a span pf text in VISUAL mode, afterwad, maybe with a special key, I display a menu with all possible enitiy labels and I chose a label from menu, tagging the text.
BTW, related question: How to replace selected text T with some function(T), using a keyboard shortcut?
Any suggestion is welcome. Thanks
:h conceal
and:h 'conceallevel'
. That's Vim's mechanism for showing/hiding text. Note that you get "show concealed text when cursor is on the same line" behavior for free with this which is not the same as "show concealed text when editing" but perhaps an acceptable substitute.'concealcursor'
setting that DBK mentioned which could produce the "while editing only" behavior for the cursor line is explicitly unset).