How tobiia/tasc works
1. This repo has two main products.
The first is the LSC analysis library in lib/LSC, which computes lexical semantic change scores from two corpora. The second is the TASC interactive app in src/, which serves a backend API and a React/Plotly frontend for 3D topic-aware visualization.
2. The LSC library is a staged pipeline.
lsc/extraction/word_extractor.py and word_cache.py identify candidate terms from corpora, likely with stop-word/POS filtering and cached word lists. That feeds lsc/representation/embedding_creator.py, which builds contextual embeddings for selected terms. The output is then consumed by lsc/assessment/scoring.py for semantic-shift metrics.
3. Embedding generation is a core boundary.
The repo is optimized around expensive transformer inference. lsc/representation/embed_cache.py stores embeddings as cached NPZ files so repeated runs reuse results instead of recomputing. lsc/representation/models.py defines the data structures used to move term-level results through the pipeline.
4. Semantic change scoring is separate from visualization.
lsc/assessment/scoring.py supports evaluation against gold labels and reports metrics such as APD and PRT. This is the “batch analysis” side of the system, distinct from the interactive app. The README’s score command points to this path.
5. Topic modeling is provided by a vendored Top2Vec fork.
lib/Top2Vec is bundled in-repo, not treated as an external runtime dependency. It is used by the visualization app to discover topic clusters in the analyzed corpus and provide topic labels/top words alongside semantic-change trajectories.
6. The visualization backend is the orchestration layer.
src/backend/app/main.py, core.py, and topic.py form the API server. core.py appears to handle loading corpus/embedding data and PCA fitting; topic.py handles topic extraction and related topic metadata; main.py exposes the endpoints and startup/shutdown lifecycle. This backend is the bridge between cached NLP outputs and the UI.
7. The frontend is a single-page visualization client.
src/frontend is a Vite/React app with Plotly-based 3D rendering. App.jsx is the root container, api.js talks to the backend, Plotly.jsx wraps chart behavior, and the components directory splits the UI into word selection, topic lists, word lists, occurrence/sentence examples, and the plot canvas.
8. Data flows from corpora to caches to API to UI.
Raw text corpora are read from dataset directories, transformed into embeddings, then reused from cache on subsequent runs. The backend combines those embeddings with PCA projections and topic-model output, and the frontend renders word trajectories, topic clusters, and example sentences for selected lemmas.
9. The repository is dataset- and cache-driven.
The README’s corpus layout under corpora/ and the cache naming conventions are important architectural constraints. Cache keys are derived from dataset names, and config.toml / src/config.py / lib/LSC/src/lsc/config.py hold the paths that bind the selected dataset to the pipeline.
10. There are multiple execution modes.
The root pyproject.toml, src/cli.py, Run.bat, run.sh, and the .app wrappers indicate packaged entry points for both production and development. The app can be launched as a local visualization service, while the LSC library can be used independently for offline scoring/evaluation.
11. Build and installation are split across Python and Node.
scripts/install.py, install.sh, install.bat, and build_zip.py automate environment setup and release packaging. The frontend has its own package.json/Vite toolchain, while the Python side packages the analysis library and backend.
12. The main architectural boundary is “analysis engine” vs “interactive presentation.”
lib/LSC and lib/Top2Vec implement NLP computation; src/backend adapts those results into API-ready data; src/frontend renders the final interactive experience. That separation is what you would draw first in an architecture diagram.
Main entry points: App.jsx Frontend app · embedding_creator.py Embedding creator · core.py Core data · main.py API server
Components 22
Analysis engine
Offline lexical semantic change pipeline and bundled topic modeling
- Corpora · Source text collections and dataset-specific inputs used by both analysis and app
README.md - Word extractor · Finds target lemmas from corpora with filtering and cache support
lib/LSC/src/lsc/extraction/word_extractor.py - Word cache · Stores extracted word lists for reuse across runs
lib/LSC/src/lsc/extraction/word_cache.py - Embedding creator · Builds contextual embeddings for selected terms
lib/LSC/src/lsc/representation/embedding_creator.py - Embedding cache · Persists expensive embedding outputs to avoid recomputation
lib/LSC/src/lsc/representation/embed_cache.py - Models · Data structures passed between extraction, embedding, and scoring stages
lib/LSC/src/lsc/representation/models.py - Scoring · Computes lexical semantic change metrics and evaluation against gold labels
lib/LSC/src/lsc/assessment/scoring.py - Top2Vec · Vendored topic discovery and labeling library used by the app
lib/Top2Vec/top2vec/top2vec.py - LSC config · Configures corpus paths and analysis pipeline settings
lib/LSC/src/lsc/config.py
Interactive app
Backend API and React frontend for topic-aware visualization
- API server · Starts the backend service and exposes endpoints to the frontend
src/backend/app/main.py - Core data · Loads corpus and embedding data and prepares PCA-ready state
src/backend/app/core.py - Topic service · Derives topic clusters and topic metadata for visualization
src/backend/app/topic.py - Frontend app · Root client container for the interactive visualization
src/frontend/src/App.jsx - API client · Fetches backend data for the UI
src/frontend/src/api.js - Plotly view · Encapsulates Plotly chart behavior for semantic trajectories
src/frontend/src/Plotly.jsx - Plot canvas · Renders the 3D trajectory and topic-aware scatter view
src/frontend/src/components/PlotCanvas.jsx - Topic list · Shows discovered topics and related metadata
src/frontend/src/components/TopicList.jsx - Word list · Lets users browse and select tracked lemmas
src/frontend/src/components/WordList.jsx - Examples panel · Displays occurrence and sentence evidence for selected words
src/frontend/src/components/OccurrenceBar.jsx
Connections 24
- Corpora → Word extractor: read terms · Corpora are scanned to identify candidate lemmas
- Word extractor → Word cache: cache lists · Extracted word sets are persisted for reuse
- Word cache → Embedding creator: select terms · Cached target terms feed embedding generation
- Embedding creator → Embedding cache: store vectors · Generated contextual embeddings are cached on disk
- Embedding creator → Models: emit results · Embedding outputs are packaged into pipeline data models
- Embedding cache → Scoring: reuse embeddings · Cached embeddings are consumed by scoring and evaluation
- Models → Scoring: score shifts · Structured term-level outputs feed semantic change metrics
- LSC config → Word extractor: paths · Pipeline configuration binds analysis inputs
- LSC config → Embedding creator: model config · Embedding generation depends on configured resources
- Corpora → Core data: load data · Backend loads corpus data for visualization state
- Embedding cache → Core data: serve vectors · Backend reads cached embeddings for projections and lookup
- Core data → Topic service: shared state · Topic analysis builds on loaded corpus and embedding state
- Top2Vec → Topic service: topic discovery · Vendored topic model provides clusters and labels
- Core data → API server: register data · Core services are exposed through the API server
- Topic service → API server: register topics · Topic endpoints and metadata are exposed through the API server
- API server → API client: serve API · Frontend fetches analysis and topic data from the backend
- API client → Frontend app: hydrate UI · Fetched data drives the root app state
- Frontend app → Plotly view: render chart · Root app delegates plot rendering to the Plotly wrapper
- Plotly view → Plot canvas: draw trajectories · Plotly wrapper powers the 3D visualization canvas
- Frontend app → Topic list: show topics · Topic metadata is surfaced in the selection panel
- Frontend app → Word list: show words · Tracked lemmas are surfaced for user selection
- Frontend app → Examples panel: show evidence · Selected lemmas reveal occurrence and sentence examples
- CLI → API server: start service · CLI can launch the backend application
- Installer → Launchers: prepare release · Installation scripts produce runnable app wrappers