There are several problems open in this free sketch of a solution.
First we need a graphic primitive how to highlight the pos
"word" //
Framed[#, FrameStyle -> Red, RoundingRadius -> 10,
FrameMargins -> 10, Background -> Lighter@LightRed] &
This only works in the postfix form!
Now we need to get the pos tags into our text. It turns out that only
TextStructure["The cat sat on the mat.", "ConstituentStrings"]
works. The output is
{"(Sentence, ((NounPhrase, (Determiner, The), (Noun, cat)), \
(VerbPhrase, (Verb, sat), (PrepositionalPhrase, (Preposition, on), \
(NounPhrase, (Determiner, the), (Noun, mat)))), (Punctuation, .)))"}
That is not a string in Mathematica nor an expression.
We have to get rid of the Sentence and the Punctuation, and if punctuation is in the text we have to extra handle this as well.
I skip this passage and will add it later.
It is possible to cut text into sentences with a built-in.
After having converted the above construct to a string we can proceed further.
A possible reduction is
Grid[Partition[(Framed[#,
FrameStyle ->
Switch[ToString[#], "NounPhrase", Red, "Noun", Red,
"Determiner", Red, "VerbPhrase", Blue, "Verb", Blue,
"PrepositionalPhrase", Green, "Preposition", Green, _,
False], RoundingRadius -> 10, FrameMargins -> 10,
Background ->
If[Switch[ToString[#], "NounPhrase", True, "VerbPhrase", True,
"PrepositionalPhrase", True, _, False], LightGreen,
If[Switch[ToString[#], "Determiner", True, "Noun", True,
"Verb", True, "Preposition", True, _, False], LightRed,
LightBlue]]] & /@ {NounPhrase, Determiner, The, NounPhrase,
Noun, cat, VerbPhrase, Verb, sat, PrepositionalPhrase,
Preposition, on, NounPhrase, Determiner, the, NounPhrase, Noun,
mat}), 3] // Transpose]
This avoid the splines for the commentary texts to the in text places of the tags. It only uses POS tagging as built-in.
There is a nice solution how to do it on this community is places are well-defined: how can i route edges manually for a graph.
This is still far from this:
The biggest problem seem how to step further from POS tagging to the sentiment tagging of the original?