I want to annotate words /sentences for a "named entity recognition" purpose; inside a text file, I want to annotating words or sentences with this format [pattern](label)
:
[a word where the cursor is or a selected sentence, a span](entity_name)
Suppose I have this text file:
# untagged.yaml
- intent: body_temperature_data
examples: |
- il termometro misura 36.3 gradi
- 36.9
- 35,9
- la temperatura è di 36 e 7 gradi
- 36 , 8
I want by example to tag decimal numbers assigning the entity body_temperature
to each of them, transforming the original file in this one:
# after_tagging.yaml
- intent: body_temperature_data
examples: |
- il termometro misura [36.3](body_temperature) gradi
- [36.9](body_temperature)
- temperatura: [35,9](body_temperature)
- la temperatura è di [36 e 7](body_temperature) gradi
- [36 , 8](body_temperature)
What I need is a vim way to quickly substitute this line:
- il termometro misura 36.3 gradi
in this line:
- il termometro misura [36.3](body_temperature) gradi
Now, suppose I'm with cursor inside a word (a number in fact):
36.3
I want to substitute the (selected) word or sentence, with a keyboard shortcut in
[36.3](body_temperature)
So the original pattern 36.3
would be "decorated" with [pattern](label)
I know the basic substitute command:
s/selected_pattern/replace
and in this special case I want to do something like
s/pattern/[pattern](label)
But i do not know the syntax to make this replacement, maybe something like this (still not working):
'<,'>s/'<,'>/[\0](body_temperature)
- let assume
body_temperature
is in a short list of options (label_1, label_2, label_N) maybe stored in a vimscript variable I can assign. - I would like to trigger the substitution with a keyboard shortcut (e.g. F1 key).
How can I do that?
BTW, that's part of the bigger problem here detailed: Vim editor entities tagging/annotation tool
thanks