7
$\begingroup$

This screenshot is from a presentation by Brian Frezza at Wolfram Data Summit 2014.

In what clearly is a Mathematica notebook. How is the text highlighted with the callouts?

enter image description here

Some sample text (Julius Caesar) with computed parts-of-speech:

TextStructure[
  StringTake[
   Import["http://shakespeare.mit.edu/julius_caesar/full.html", 
    "HTML"], {969, 1150}], "PartsOfSpeech"] // 
 Query[1, 1, 1, 
  All, {Query[1], 
   Query[2, Values /* Replace[{Entity[_, pos_]} :> pos]]}]

{{Second,Adjective},{Commoner,Noun},{Nay,ProperNoun},{,,Punctuation},{I,Pronoun},{beseech,Verb},{you,Pronoun},{,,Punctuation},{sir,Noun},{,,Punctuation},{be,Verb},{not,Adverb},{out,Particle},{with,Preposition},{me,Pronoun},{:,Punctuation},{yet,Adverb},{,,Punctuation},{if,Preposition},{you,Pronoun},{be,Verb},{out,Adverb},{,,Punctuation},{sir,Noun},{,,Punctuation},{I,Pronoun},{can,Verb},{mend,Verb},{you,Pronoun},{.,Punctuation}}

$\endgroup$
10
  • 1
    $\begingroup$ My bet is on drawing tools but could you provide data to work with in case it is not or when someone wants to try it? That is a text sample, text parts spec + labels. $\endgroup$
    – Kuba
    Commented Mar 1, 2018 at 7:03
  • $\begingroup$ It is a bitmap image (several of them actually within a FlipView) pasted into a Mathematica notebook wolframdatasummit.org/2014/attendee/presentations $\endgroup$ Commented Mar 1, 2018 at 7:13
  • $\begingroup$ @MikeHoneychurch, were the bitmaps generated in Mathematica or imported? $\endgroup$ Commented Mar 1, 2018 at 7:23
  • $\begingroup$ @Kuba, added some sample text & tags, though they're paired in lists. Could randomly subselect some tags and drop others. $\endgroup$ Commented Mar 1, 2018 at 7:26
  • $\begingroup$ @alancalvitti thanks. p.s. this may be helpful: mathematica.stackexchange.com/q/155237/5478 $\endgroup$
    – Kuba
    Commented Mar 1, 2018 at 8:02

1 Answer 1

-3
$\begingroup$

I think this is an example closer to the requirements of the question:

dynamic linkage of LocatorPane and InputField.

InputField and Overlay and

DynamicModule[{z = 120}, 
 Panel@Column[{Style["Degree", 16], 
    Overlay[{Experimental`AngularSlider[
       Dynamic[z, (z = Round[#, 1]) &], {0, 360}, 
       Experimental`BoundaryAction -> "Wrap", ImageSize -> 200], 
      Graphics[{Text[
         Framed[Style[Dynamic[Round[z, 1]] \[Degree], 16], 
          FrameStyle -> None], Scaled@{3/4, 4/10}, {-1, 1}], 
        Text[Framed[Style[Dynamic[Round[z Degree, Pi/2^7]], 16], 
          FrameStyle -> None], Scaled@{3/4, 4/10}, {-1, -1}]}]}, All, 
     1], InputField[Dynamic[z, (z = Round[#, 1]) &], 
     ImageSize -> {100, 24}, BaseStyle -> 16]}, Alignment -> Center]]

example InputField with dynamic placement of Line and Text.

This is an example moving the framed text around even in a plot:

automatic-placement-of-legend-box-with-placed-equivalent-to-best-in-matplot

This shows how to define Your own overlay graphics and display them dynamically over a given background object:

optional-grid-in-overlay

From the Mathematica Overlay documentation stems the idea to overlay plot on texts:

Overlay[{StringTake[ExampleData[{"Text", "ToBeOrNotToBe"}], 400], 
  Plot[Sin[E^-x], {x, 0, 5}]}]

The splines are done with Spline offered in the standard of Mathematica.

There is only the need to put this all together. There is an example over at the Mathematica Demonstration named Pottery Wheel to draw such nice Splines.

Only some simple steps to show such a nice text analysis in a slide show.

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] &

word highlighted

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]

solution with reduction

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:

original by Brian Frezza

The biggest problem seem how to step further from POS tagging to the sentiment tagging of the original?

At present, I think on this AmbiguityFunction. We possibly need AmbiguityList.

Some insider hint was that the document was done in https://www.v7labs.com/document-processing!

$\endgroup$
1
  • $\begingroup$ This may well be an interesting answer, but only to a different question. You've assumed the OP wants much more than he actually requested, in other words, your answer does not get closer to the requirements of the question. $\endgroup$
    – fairflow
    Commented Nov 23, 2023 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.