RESEARCH NOTES

Advanced visualisation · I: the many forms of text

Chapter 1: Why turn text into a picture?↗

Text visualization can begin with four questions. How can a reader grasp the outline of a document? Compare documents or follow their evolution? Find an entry point for grouping and topic exploration? Relate textual patterns to other data?

A picture does not guarantee faster or more accurate reading. It brings some relations forward while hiding others. Decide what needs to become visible before choosing how to compress the text.

1.1 What kind of data is text?↗

Web pages, articles, logs, books, email, comments, source code and tags can all be documents. Organizing them by author, time, community or task produces different collections.

Table 1. Text characteristics and units of analysis
Characteristic Implication for visualization
Abstraction Characters need not resemble what they refer to
Sequence Word order can change meaning; prose is usually read sequentially
Multiple levels Words, sentences, paragraphs, grammar and typography offer different units of analysis
Variation across groups and settings The same word can serve different purposes across communities, genres and contexts

1.2 More than too many words↗

Table 2. Challenges in text visualization
Challenge What must be decided?
High dimensionality Which terms, relations and levels should survive?
Keywords Are frequency, distinctiveness and descriptiveness the same thing?
Context How much text preserves negation, modification and whom a statement addresses?
Meaning How should ambiguous forms, synonyms and metaphor be handled?
Access to the source Can readers return from the view to the relevant passage?
Domain structure Does a classification or ontology require additional domain knowledge?

Terms can be counted as categories without reducing their meanings to equality tests. Paris, New York and Madrid share a city category; that list alone establishes no statistical correlation. January, February and March have a calendar order, but arbitrary vocabularies have no natural ordering. Inflection is also different from synonymy, antonymy and hierarchical relations.

Chapter 2: Processing is not one fixed pipeline↗

Tokenization, entity recognition, stemming and lemmatization are different operations. They can be combined without always running every step in one order. Stemming and lemmatization are often alternatives chosen for a task.

Table 3. Processing operations and their boundaries
Operation Purpose Example and boundary
Tokenization Segment characters into tokens while retaining alignment with the source “a sentence” can yield two tokens; punctuation may also be retained
Filtering Decide whether to remove stop words, numbers or symbols This is not the definition of tokenization; negation and prepositions may be the object of study
Named entity recognition Identify spans referring to people, organizations, places and other categories James Bond may be tagged as a person; categories depend on the model and annotation scheme
Stemming Merge some forms through rules; the result need not be a complete word fishing and fished may reduce to fish; rules differ
Lemmatization Recover a base form using dictionaries, rules or models went can map to go; results may depend on part of speech and context
Vocabulary indexing Assign computational identifiers to terms The IDs for go and good encode no magnitude, distance or semantic order

spaCy’s linguistic-feature documentation distinguishes these operations. Informal text, abbreviations, names and multiword entities need separate attention. Preserve surface forms or source offsets for presentation: a stem generally cannot be uniquely reversed.

Tools such as Gensim and spaCy can help implement the processing, but the unit of analysis comes first. If the question concerns “X and Y,” deleting and at the start removes the very connection the later network is meant to find.

Chapter 3: Bags, matrices and clouds↗

3.1 A document as a vector↗

A basic bag-of-words representation counts terms while discarding their positions. It may use unigrams or extend to n-grams. The latter preserve local order without preserving the arrangement of all phrases in the document. Omitting order from a representation does not assert that terms are statistically independent.

For DD documents and a vocabulary of VV terms, a document–term count matrix can be written as:

Xdv=count⁡(v in d),X∈RD×V.X_{dv}=\operatorname{count}(v\text{ in }d),\qquad X\in\mathbb{R}^{D\times V}.

Rows represent documents and columns represent terms. scikit-learn’s text-feature guide uses this convention. The original note’s transposed layout below makes the plays easier to compare. Its values come from a teaching table in the related lecture, rather than a corpus recounted for this revision.

Table 4. Teaching example: term counts in Shakespeare plays
Term Antony and Cleopatra Julius Caesar The Tempest Hamlet Othello Macbeth
Antony 157 73 0 0 0 0
Brutus 4 157 0 1 0 0
Caesar 232 227 0 2 1 1
Calpurnia 0 10 0 0 0 0
Cleopatra 57 0 0 0 0 0
mercy 2 0 3 5 5 1
worser 2 0 1 1 1 0

Counts are only one weighting scheme. Relative frequency, Xdv/∑uXduX_{dv}/\sum_uX_{du}, can help compare documents of different lengths when the denominator is positive. TF–IDF answers another question. Frequency, distinctiveness and usefulness to a reader are not interchangeable.

3.2 Word clouds: visibility has a cost↗

Tag clouds commonly encode frequency or another weight through type size. They can suggest a useful query without supporting precise comparisons.

Table 5. Uses and limitations of word clouds
What they can support What they can obscure
Finding prominent terms Grammar, relations and negation
Forming a query Size and arbitrary placement are often harder to compare than positions on a shared scale
Quick scanning Longer words occupy more area without necessarily having greater weight
An overview Unstable layouts complicate comparisons between documents

3.3 Recovering a modifier↗

Frequent mentions of “service” do not yet distinguish praise from complaint. “Slow service” retains a relation. Adjective–noun pairs can therefore be useful for summarizing reviews, without being universally superior to bags of words. Extraction can fail, and irony, negation and longer contexts may still be lost.

Words versus phrases: service/food/wait and slow service/fresh food/long wait.
Concept illustration: modifiers preserve some relations lost by isolated counts. Words and type sizes are illustrative, not review data or exact frequencies. Enlarge ↗

Chapter 4: Putting local context back↗

4.1 Beyond a matching string↗

Retrieval can show the text around a hit as well as match a query, highlighting the query term within it. Keyword-in-context (KWIC) reconnects occurrence with use. SeeSoft and TileBars offer different historical examples in the related course material; they need not be treated as a current list of ready-to-use software.

The interface should provide a route back to the sentence. Otherwise, a striking word may come from a passage whose negation or quotation marks have disappeared.

4.2 WordTree: where repetition branches↗

Wattenberg and Viégas’s WordTree starts from a query word or phrase and organizes repeated following or preceding sequences as a tree. Shared prefixes merge before branching at different words. This is not a syntactic parse tree or simply a list of fixed-length n-grams.

A Thank you word tree with paths for sharing, for your help, and so much for coming.
How to read a WordTree: follow branches to reconstruct phrases. The three phrases are invented teaching examples, not the original web corpus or counts. Enlarge ↗

The starting point determines which local structures become visible. Exact matching separates lexical and syntactic variants. Filtering rare branches improves legibility, but the remaining display is no longer the complete distribution. Jason Davies’s interactive implementation offers a way to explore this form of querying.

4.3 Phrase Nets: define the relation first↗

Phrase Nets find a specified relation, such as “X and Y” or “X at Y,” or use the output of syntactic analysis. Matches become a node–link view. In the original design, occurrences can affect node size and pattern position can determine edge direction. Changing the pattern changes the network. See Mapping Text with Phrase Nets.

An X and Y phrase network: bread to butter and jam, and butter to jam.
A network from the invented phrases bread and butter, bread and jam, and butter and jam. Arrows encode word order; equal-sized nodes encode no measured counts. Enlarge ↗

An edge first establishes a match to the chosen relation; it does not automatically establish a causal, psychological or social connection. The extraction rule belongs alongside the graph’s interpretation.

Chapter 5: Documents have positions, versions and participants↗

5.1 Content and interaction↗

Table 6. Perspectives on document content
Perspective Relations that may be retained
Within a document Term position, sequence, paragraphs and hierarchy
Between documents Similarities or groups computed from explicit features
Layout Map selected relations into space without assuming every distance has semantic meaning
Interaction Browse, brush, link views, return to passages and revise query patterns

5.2 Beyond the final version↗

Revision records can reveal when passages were added, removed or retained. Wikipedia’s History Flow and Git histories concern different objects. Animation is one way to present time, rather than a requirement.

The original note illustrated this section with Ben Fry’s The Preservation of Favoured Traces, which follows six editions of On the Origin of Species, rather than Wikipedia edits. The schematic here does not use the book’s data; the original project remains available through the link.

Three text versions: four earlier segments, a brass insertion, then a blue-gray insertion.
Revision-history schematic: gray earlier text, brass and blue-gray successive additions. Segment lengths, links and versions are illustrative, not Darwin edition data or a reproduction of the original project. Enlarge ↗

5.3 Conversation: who, what and when↗

Conversations can be examined by sender and recipient, content, time and combinations of these dimensions. Message volume alone does not establish the quality of a relationship. Terms alone may not reveal who is replying to whom.

Three participants at three times: A to B, B to A, and C to B.
Invented conversation schematic: time runs horizontally, lanes separate participants, arrows indicate sender and recipient. Activity structure does not establish closeness, emotion or actual message content. Enlarge ↗

Historical designs include Newsgroup Crowds, AuthorLines, Mountain and Themail. Themail connects the terms in an email correspondence with time and provides access to the original messages. Such designs help formulate more specific reading questions without explaining an entire relationship on its participants’ behalf.

Chapter 6: From collections to latent topics↗

6.1 Comparing side by side↗

Table 7. Ways to compare document collections
Method Question
Parallel tag clouds Which terms stand out in each subset, and how does one term recur across groups?
Document projections Which documents appear close in a low-dimensional view of a specified representation and distance?
Topic-model views How do documents relate to topics, and topics to terms?

Collins and colleagues’ Parallel Tag Clouds combine a parallel layout with tag clouds and access to individual texts. Comparison involves more than placing independent clouds side by side. Term selection, weight scales, absences and cross-column tracing all affect what can be read.

Model, data and memory across three document groups; links trace memory.
Simplified parallel terms: a fixed order supports comparison and links trace one term. Type sizes indicate illustrative prominence, not the paper’s legal corpus or fitted weights. Enlarge ↗

6.2 LSA: a low-rank approximation↗

Latent semantic analysis (LSA) applies truncated singular value decomposition to a count or TF–IDF matrix. With documents as rows and terms as columns:

X≈UkΣkVkT.X\approx U_k\Sigma_kV_k^{\mathsf T}.

The dimensions of UkU_k, Σk\Sigma_k and VkV_k are D×kD\times k, k×kk\times k and V×kV\times k. Retaining kk singular directions gives a lower-dimensional representation. This use of SVD does not make every direction a directly nameable probabilistic topic.

6.3 LDA: a mixture is not a classification↗

Latent Dirichlet allocation (LDA) is a generative model. A document has a mixture of topics; each topic is a probability distribution over the vocabulary. Given document dd’s mixture weights θd\theta_d and topic–term probabilities ϕ\phi, the probability of a token taking value vv is:

p(w=v∣θd,ϕ)=∑k=1Kθdkϕkv.p(w=v\mid\theta_d,\phi)=\sum_{k=1}^{K}\theta_{dk}\phi_{kv}.

Here θdk≥0\theta_{dk}\geq0, ∑kθdk=1\sum_k\theta_{dk}=1, and each topic satisfies ϕkv≥0\phi_{kv}\geq0, ∑vϕkv=1\sum_v\phi_{kv}=1. This is a token-level mixture conditional on fixed parameters. Full LDA also includes a prior over document mixtures and inference. A document can involve several topics without being assigned to one exclusive class.

A document mixture with two topics illustrated by model and music words.
Conceptual topic mixture: segments stand for topic weights and words illustrate reading topic–word distributions. Proportions and words are invented, not fitted results or an LDAvis screenshot; a topic is not thereby assigned a definitive meaning. Enlarge ↗

Calling a topic “cats” or “music” is an interpretation of its prominent terms, rather than proof that the model has acquired that concept. LDAvis links a topic overview to term views. Its two-dimensional distances depend on distributional comparisons and projection; the spaces between circles should not be mistaken for meaning itself.

Text has many forms. Each choice determines both what becomes visible and what still requires a return to the words.