|
7 | 7 | "source": [ |
8 | 8 | "# Visualization Toolkit Usage Guide\n", |
9 | 9 | "\n", |
10 | | - "This notebook provides a suite of semantic analysis and visualization tools to explore word-level patterns and relationships in qualitative text data. It supports multiple clustering and embedding strategies for t-SNE, semantic networks, and word clouds. You can review the version with explanations here https://colab.research.google.com/drive/1n90EDMSiXhIaOULUMPJ4W4hqdZCh1NQw?usp=sharing\n", |
| 10 | + "A suite of semantic-analysis and visualization tools for word-level patterns in qualitative text data — word clouds, t-SNE semantic maps, word/code heatmaps, and semantic networks. An annotated online version is on [Colab](https://colab.research.google.com/drive/1n90EDMSiXhIaOULUMPJ4W4hqdZCh1NQw?usp=sharing) (not for sensitive data); see also the [video tutorial](https://vimeo.com/1122226315) and the [working-paper description](https://github.com/Computational-Ethnography-Lab/cmap_visualization_toolkit/blob/main/documentation/paper.md).\n", |
11 | 11 | "\n", |
12 | | - "### What You Can Do with This Toolkit\n", |
| 12 | + "**Full documentation — install, usage, data schema, design notes, license — is in the [README](https://github.com/Computational-Ethnography-Lab/cmap_visualization_toolkit#readme).** This notebook is meant to be run top-to-bottom: the **Setup** and **Helper Function** cells are background setup (run them once, in order); then use the **Analytics Tool** sections to generate and customize visuals.\n", |
13 | 13 | "\n", |
14 | | - "- **Generate Word Clouds** \n", |
15 | | - " Visualize the most frequent and salient terms across your dataset or within filtered subsets based on keywords or project name.\n", |
| 14 | + "### How to run\n", |
| 15 | + "1. **Prepare your data** — a `.csv`/DataFrame with at least a `text` column (optional `project`, `codes`, `data_group` for subsetting). Full schema: [Teaching → Data Schema Example (CMAP)](https://github.com/Computational-Ethnography-Lab/teaching#data-schema-example-cmap).\n", |
| 16 | + "2. **Run Setup + Helper Functions top-to-bottom** — these load packages, define directories, stopwords / word-families, validators, and the plotting functions.\n", |
| 17 | + "3. **Run a tool section** — Basic (word cloud), Intermediate (heatmaps, t-SNE, networks), or Advanced (full / interactive). Edit the user-configuration block at the top of each section.\n", |
16 | 18 | "\n", |
17 | | - "- **Plot t-SNE Semantic Maps** \n", |
18 | | - " Reduce high-dimensional similarity or co-occurrence matrices into 2D using t-SNE to highlight semantic proximity between words. Seed words are emphasized to anchor interpretation.\n", |
19 | | - "\n", |
20 | | - "- **Create Word-Based Heatmaps and Semantic Networks** \n", |
21 | | - " Explore how terms relate to each other in both visual space and co-occurrence structure:\n", |
22 | | - " \n", |
23 | | - " - **Basic Heatmap**: Highlights semantically clustered keywords based on selected embeddings or similarity matrices.\n", |
24 | | - " - **Heatmap + Network**: Adds a basic network graph on top of the heatmap using default node/edge colors (no bundling, no category styling).\n", |
25 | | - " - **Heatmap + Network (Colored Nodes & Edges)**: Fully stylized version including colored clusters, semantic links, and optional edge styling.\n", |
26 | | - "\n", |
27 | | - "- **Visualize Code Co-Occurrence Heatmaps** \n", |
28 | | - " Plot the frequency with which qualitative codes appear together in the same entries. \n", |
29 | | - "\n", |
30 | | - "These tools help you visually investigate language patterns, conceptual clustering, and topic proximity—whether you’re doing grounded theory, thematic analysis, or exploratory semantic mapping.\n", |
31 | | - "\n", |
32 | | - "### How to Use\n", |
33 | | - "1. **Prepare Your Dataset** \n", |
34 | | - " Make sure your dataset is a `.csv` or DataFrame with at least:\n", |
35 | | - " - A `text` column (raw text)\n", |
36 | | - " - Optionally, a `project` column (for subsetting)\n", |
37 | | - " - optionally a `codes' column` (for subsetting, and analysis)\n", |
38 | | - " - Please see READ.md for the complete schema and more possibilities.\n", |
39 | | - "\n", |
40 | | - "2. **Set Key Parameters** \n", |
41 | | - " Most functions accept:\n", |
42 | | - " - `stopwords_path`: path to extra stopwords (optional)\n", |
43 | | - " - `clustering_method`: 1 = RoBERTa, 2 = Jaccard, 3 = PMI, 4 = TF-IDF\n", |
44 | | - " - `distance_metric`: \"cosine\" or \"default\" (used for similarity matrix choice)\n", |
45 | | - "\n", |
46 | | - "3. **Run Visualizations**\n", |
47 | | - "You can explore and generate a variety of visual outputs using the execution blocks provided in the **Analytics Tools** and **Advanced Analytics Tools** sections.\n", |
48 | | - "\n", |
49 | | - "These include:\n", |
50 | | - "- **Word Clouds** for highlighting high-frequency terms in selected texts or projects.\n", |
51 | | - "- **t-SNE Semantic Maps** to project word relationships into 2D space for visualizing proximity and clusters.\n", |
52 | | - "- **Word-Based Heatmaps** to show how frequently words co-occur.\n", |
53 | | - "- **Semantic Network Graphs** (with optional heatmaps), including:\n", |
54 | | - " - show relationships in text\n", |
55 | | - " - basic node/seed networks,\n", |
56 | | - " - networks with customized node colors,\n", |
57 | | - " - and networks with or without edge bundling.\n", |
58 | | - "- **Code-based Heatmap** to visualize co-occurrence patterns among qualitative codes\n", |
59 | | - "\n", |
60 | | - "📍 Simply scroll down to the relevant execution cells to run and customize these visualizations based on your dataset.\n", |
61 | | - "\n", |
62 | | - "### File Structure Notes\n", |
63 | | - "- Define constants like `DATA_DIR`, `OUTPUT_DIR`, and stopword files before running.\n", |
64 | | - "- Ensure required files and embeddings are preloaded or generated using prior pipeline steps.\n", |
65 | | - "\n", |
66 | | - "> Tip: Start by testing on one project or topic before scaling to all data.\n", |
67 | | - "\n", |
68 | | - "# TESTING\n", |
| 19 | + "**Key parameters (set per tool):** `clustering_method` 1 = RoBERTa, 2 = Jaccard, 3 = PMI, 4 = TF-IDF; `distance_metric` `\"cosine\"` or `\"default\"`. Design rationale for the environment-configuration and word-family setup steps is in [README → Design Notes](https://github.com/Computational-Ethnography-Lab/cmap_visualization_toolkit#design-notes).\n", |
69 | 20 | "\n", |
70 | 21 | "## License & Citation\n", |
71 | 22 | "\n", |
72 | | - "**License:** [BSD 3-Clause](https://opensource.org/license/bsd-3-clause/) · “AS IS” — no warranties or liability.\n", |
73 | | - "\n", |
74 | | - "**Citation:** *Abramson, Corey M. and Yuhan (Victoria) Nian. 2025. CMAP Visualization Toolkit.* <https://github.com/Computational-Ethnography-Lab/cmap_visualization_toolkit>\n", |
75 | | - "\n", |
76 | | - "For questions or use requests, please email <corey.abramson@rice.edu>." |
| 23 | + "BSD 3-Clause (\"AS IS\", no warranty). **Cite as:** Abramson, Corey M. and Yuhan (Victoria) Nian. 2025. *CMAP Visualization Toolkit.* Full citation with the Zenodo DOI and contributor list is in the [README](https://github.com/Computational-Ethnography-Lab/cmap_visualization_toolkit#policies). Questions: <corey.abramson@rice.edu>." |
77 | 24 | ] |
78 | 25 | }, |
79 | 26 | { |
|
241 | 188 | "source": [ |
242 | 189 | "### Environment Configuration\n", |
243 | 190 | "\n", |
244 | | - "In this section, we define the core directory structure used throughout the replication project. These paths help organize:\n", |
245 | | - "\n", |
246 | | - "- **raw data**, \n", |
247 | | - "- **trained models**, \n", |
248 | | - "- **clustering results**, and \n", |
249 | | - "- **final outputs**.\n", |
250 | | - "\n", |
251 | | - "This setup also makes it easier for users to customize where intermediate results and final outputs will be saved. For example, by changing these directory names, users can **create their own versions of model runs or clustering outputs without overwriting previous results.**\n", |
252 | | - "\n", |
253 | | - "All directories will be automatically created if they don't already exist." |
| 191 | + "Defines the core directory structure (raw data, models, clustering results, outputs); all directories are auto-created. Change these names to keep separate model/clustering runs without overwriting previous results. **Full rationale:** [README → Design Notes](https://github.com/Computational-Ethnography-Lab/cmap_visualization_toolkit#design-notes)." |
254 | 192 | ] |
255 | 193 | }, |
256 | 194 | { |
|
357 | 295 | "source": [ |
358 | 296 | "### Stopword Expansion and Semantic Word Family Definitions\n", |
359 | 297 | "\n", |
360 | | - "This section defines a comprehensive list of stopwords, extending NLTK’s default stopword set with:\n", |
361 | | - "- **punctuation**, \n", |
362 | | - "- **contractions**, \n", |
363 | | - "- **common filler words**, and \n", |
364 | | - "- **project-specific conversational terms** that are semantically uninformative in analysis.\n", |
365 | | - "\n", |
366 | | - "We also build a custom `WORD_FAMILIES` dictionary, which groups related words into unified concepts (e.g., \"death\", \"caregiver\", \"memory\"). This allows the model to:\n", |
367 | | - "- **compress synonyms and variations** into semantically meaningful units,\n", |
368 | | - "- **reduce noise** in the embedding space,\n", |
369 | | - "- and **support cultural/qualitative interpretation** of the results.\n", |
370 | | - "\n", |
371 | | - "This section also includes validation checks to:\n", |
372 | | - "- Ensure **no accidental overlaps** between stopwords and key analytical terms,\n", |
373 | | - "- Detect **redundant words across families**, \n", |
374 | | - "- And print summaries for user verification.\n", |
375 | | - "\n", |
376 | | - "These definitions are critical for interpretability in downstream visualization and clustering." |
| 298 | + "Extends NLTK's stopwords (punctuation, contractions, filler, project-specific terms) and builds the `WORD_FAMILIES` dictionary that groups related words into unified concepts — compressing synonyms, reducing embedding noise, and supporting qualitative interpretation. Validation checks flag stopword/analytical-term overlaps and redundant families. **Full rationale:** [README → Design Notes](https://github.com/Computational-Ethnography-Lab/cmap_visualization_toolkit#design-notes)." |
377 | 299 | ] |
378 | 300 | }, |
379 | 301 | { |
|
3139 | 3061 | "This section contains advanced heatmap and network combined execution blocks." |
3140 | 3062 | ] |
3141 | 3063 | }, |
3142 | | - { |
3143 | | - "cell_type": "markdown", |
3144 | | - "id": "bcbc21be", |
3145 | | - "metadata": {}, |
3146 | | - "source": [] |
3147 | | - }, |
3148 | 3064 | { |
3149 | 3065 | "cell_type": "code", |
3150 | 3066 | "execution_count": null, |
|
3686 | 3602 | "if __name__ == \"__main__\":\n", |
3687 | 3603 | " main()" |
3688 | 3604 | ] |
3689 | | - }, |
3690 | | - { |
3691 | | - "cell_type": "code", |
3692 | | - "execution_count": null, |
3693 | | - "id": "536568e4-3b86-4507-852a-9bee92d6d18e", |
3694 | | - "metadata": {}, |
3695 | | - "outputs": [], |
3696 | | - "source": [] |
3697 | | - }, |
3698 | | - { |
3699 | | - "cell_type": "code", |
3700 | | - "execution_count": null, |
3701 | | - "id": "1ddb3204-ce24-4895-8c23-ed640eb6e407", |
3702 | | - "metadata": {}, |
3703 | | - "outputs": [], |
3704 | | - "source": [] |
3705 | | - }, |
3706 | | - { |
3707 | | - "cell_type": "code", |
3708 | | - "execution_count": null, |
3709 | | - "id": "d443a3f1-86ae-4d39-bd87-9781538cd388", |
3710 | | - "metadata": {}, |
3711 | | - "outputs": [], |
3712 | | - "source": [] |
3713 | 3605 | } |
3714 | 3606 | ], |
3715 | 3607 | "metadata": { |
|
0 commit comments