Semantic analysis interprets and stores the meaning of words, phrases, or statements instead of treating language as word or character counts. It uses structured numerical representations and statistical relationships to help resolve ambiguity without relying on brittle, exhaustive grammar rules. section 1.2.3
A practical route is to analyze term co-occurrence. Words that appear in similar documents can receive related representations, allowing an algorithm to estimate relationships such as the synonymy between “apple” and “NYC” in a corpus. section 4.1.3
From word counts to topics
A small vocabulary—cat, dog, apple, lion, NYC, and love—can be assigned TF–IDF values and combined with positive or negative weights to form petness, animalness, and cityness topic vectors. Transposing the topic matrix produces word vectors, while later SVD-based transformations derive topics from TF–IDF or BOW representations. section 4.1.3 section 4.11
Listing 4.1 Sample weights for your topics
>>> import numpy as np
>>> topic = {}
>>> tfidf = dict(list(zip('cat dog apple lion NYC love'.split(),
... np.random.rand(6)))) #1
>>> topic['petness'] = (.3 * tfidf['cat'] +\
... .3 * tfidf['dog'] +\
... 0 * tfidf['apple'] +\
... 0 * tfidf['lion'] -\
... .2 * tfidf['NYC'] +\
... .2 * tfidf['love']) #2
>>> topic['animalness'] = (.1 * tfidf['cat'] +\
... .1 * tfidf['dog'] -\
... .1 * tfidf['apple'] +\
... .5 * tfidf['lion'] +\
... .1 * tfidf['NYC'] -\
... .1 * tfidf['love'])
>>> topic['cityness'] = ( 0 * tfidf['cat'] -\
... .1 * tfidf['dog'] +\
... .2 * tfidf['apple'] -\
... .1 * tfidf['lion'] +\
... .5 * tfidf['NYC'] +\
... .1 * tfidf['love'])
Inspect the executable NumPy thought experiment that combines weighted word values into topic vectors. section 4.1.3
The resulting topic vectors support semantic search: documents can be retrieved by inferred meaning rather than exact word matches. Explainable topic analysis can use LDiA, while model and pipeline choices can be compared with a hyperparameter table. section 4.11
