|
16 | 16 | "2. **Run Setup + Helper Functions top-to-bottom** — these load packages, define directories, stopwords / word-families, validators, and the plotting functions.\n", |
17 | 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", |
18 | 18 | "\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", |
| 19 | + "**Key parameters (set per tool):** `clustering_method` 1 = RoBERTa, 2 = Co-occurrence, 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", |
20 | 20 | "\n", |
21 | 21 | "## Core principles \n", |
22 | 22 | "- Abramson, C. M., Prendergast, T., Li, Z., & Dohan, D. (2026). \"Qualitative Research in an Era of Artificial Intelligence: A Pragmatic Approach to Data Analysis, Workflow, and Computation.\" *Annual Review of Sociology, 52* (in press). https://doi.org/10.1146/annurev-soc-011824-104836\n", |
|
899 | 899 | " print(\"Method: RoBERTa – Shows semantic relationships based on contextual embeddings\")\n", |
900 | 900 | " elif input_data.clustering_method == 2:\n", |
901 | 901 | " if input_data.distance_metric == \"cosine\":\n", |
902 | | - " print(\"Method: Jaccard (cosine) – Uses context window vectors to compute cosine-based similarity between word usage patterns\")\n", |
| 902 | + " print(\"Method: Co-occurrence (cosine) – Uses context window vectors to compute cosine-based similarity between word usage patterns\")\n", |
903 | 903 | " elif input_data.distance_metric == \"default\":\n", |
904 | | - " print(\"Method: Jaccard (default) – Uses binary co-occurrence counts within a context window to capture word overlap\")\n", |
| 904 | + " print(\"Method: Co-occurrence (Jaccard index, default) – Uses binary co-occurrence counts within a context window to capture word overlap\")\n", |
905 | 905 | " elif input_data.clustering_method == 3:\n", |
906 | 906 | " if input_data.distance_metric == \"cosine\":\n", |
907 | 907 | " print(\"Method: PMI (cosine) – Highlights statistically significant word associations using cosine similarity of PMI-weighted context vectors\")\n", |
908 | 908 | " elif input_data.distance_metric == \"default\":\n", |
909 | | - " print(\"Method: PMI (default) – Highlights statistically significant word associations using raw PMI scores\")\n", |
| 909 | + " print(\"Method: PMI (default) – Highlights statistically significant word associations using positive PMI (PPMI) scores\")\n", |
910 | 910 | " elif input_data.clustering_method == 4:\n", |
911 | 911 | " if input_data.distance_metric == \"raw_weighted\":\n", |
912 | 912 | " print(\"Method: TF-IDF (raw weighted) – Uses raw TF-IDF-weighted co-occurrence scores for word associations\")\n", |
|
1176 | 1176 | " print(\"Method: RoBERTa – Shows semantic relationships based on contextual embeddings\")\n", |
1177 | 1177 | " elif input_data.clustering_method == 2:\n", |
1178 | 1178 | " if input_data.distance_metric == \"cosine\":\n", |
1179 | | - " print(\"Method: Jaccard (cosine) – Uses context window vectors to compute cosine-based similarity between word usage patterns\")\n", |
| 1179 | + " print(\"Method: Co-occurrence (cosine) – Uses context window vectors to compute cosine-based similarity between word usage patterns\")\n", |
1180 | 1180 | " elif input_data.distance_metric == \"default\":\n", |
1181 | | - " print(\"Method: Jaccard (default) – Uses binary co-occurrence counts within a context window to capture word overlap\")\n", |
| 1181 | + " print(\"Method: Co-occurrence (Jaccard index, default) – Uses binary co-occurrence counts within a context window to capture word overlap\")\n", |
1182 | 1182 | " elif input_data.clustering_method == 3:\n", |
1183 | 1183 | " if input_data.distance_metric == \"cosine\":\n", |
1184 | 1184 | " print(\"Method: PMI (cosine) – Highlights statistically significant word associations using cosine similarity of PMI-weighted context vectors\")\n", |
1185 | 1185 | " elif input_data.distance_metric == \"default\":\n", |
1186 | | - " print(\"Method: PMI (default) – Highlights statistically significant word associations using raw PMI scores\")\n", |
| 1186 | + " print(\"Method: PMI (default) – Highlights statistically significant word associations using positive PMI (PPMI) scores\")\n", |
1187 | 1187 | " elif input_data.clustering_method == 4:\n", |
1188 | 1188 | " if input_data.distance_metric == \"raw_weighted\":\n", |
1189 | 1189 | " print(\"Method: TF-IDF (raw weighted) – Uses raw TF-IDF-weighted co-occurrence scores for word associations\")\n", |
|
1583 | 1583 | " print(\"Method: RoBERTa – Shows semantic relationships based on contextual embeddings\")\n", |
1584 | 1584 | " elif input_data.clustering_method == 2:\n", |
1585 | 1585 | " if input_data.distance_metric == \"cosine\":\n", |
1586 | | - " print(\"Method: Jaccard (cosine) – Uses context window vectors to compute cosine-based similarity between word usage patterns\")\n", |
| 1586 | + " print(\"Method: Co-occurrence (cosine) – Uses context window vectors to compute cosine-based similarity between word usage patterns\")\n", |
1587 | 1587 | " elif input_data.distance_metric == \"default\":\n", |
1588 | | - " print(\"Method: Jaccard (default) – Uses binary co-occurrence counts within a context window to capture word overlap\")\n", |
| 1588 | + " print(\"Method: Co-occurrence (Jaccard index, default) – Uses binary co-occurrence counts within a context window to capture word overlap\")\n", |
1589 | 1589 | " elif input_data.clustering_method == 3:\n", |
1590 | 1590 | " if input_data.distance_metric == \"cosine\":\n", |
1591 | 1591 | " print(\"Method: PMI (cosine) – Highlights statistically significant word associations using cosine similarity of PMI-weighted context vectors\")\n", |
1592 | 1592 | " elif input_data.distance_metric == \"default\":\n", |
1593 | | - " print(\"Method: PMI (default) – Highlights statistically significant word associations using raw PMI scores\")\n", |
| 1593 | + " print(\"Method: PMI (default) – Highlights statistically significant word associations using positive PMI (PPMI) scores\")\n", |
1594 | 1594 | " elif input_data.clustering_method == 4:\n", |
1595 | 1595 | " if input_data.distance_metric == \"raw_weighted\":\n", |
1596 | 1596 | " print(\"Method: TF-IDF (raw weighted) – Uses raw TF-IDF-weighted co-occurrence scores for word associations\")\n", |
|
2033 | 2033 | " print(\"Method: RoBERTa – Shows semantic relationships based on contextual embeddings\")\n", |
2034 | 2034 | " elif input_data.clustering_method == 2:\n", |
2035 | 2035 | " if input_data.distance_metric == \"cosine\":\n", |
2036 | | - " print(\"Method: Jaccard (cosine) – Uses context window vectors to compute cosine-based similarity between word usage patterns\")\n", |
| 2036 | + " print(\"Method: Co-occurrence (cosine) – Uses context window vectors to compute cosine-based similarity between word usage patterns\")\n", |
2037 | 2037 | " elif input_data.distance_metric == \"default\":\n", |
2038 | | - " print(\"Method: Jaccard (default) – Uses binary co-occurrence counts within a context window to capture word overlap\")\n", |
| 2038 | + " print(\"Method: Co-occurrence (Jaccard index, default) – Uses binary co-occurrence counts within a context window to capture word overlap\")\n", |
2039 | 2039 | " elif input_data.clustering_method == 3:\n", |
2040 | 2040 | " if input_data.distance_metric == \"cosine\":\n", |
2041 | 2041 | " print(\"Method: PMI (cosine) – Highlights statistically significant word associations using cosine similarity of PMI-weighted context vectors\")\n", |
2042 | 2042 | " elif input_data.distance_metric == \"default\":\n", |
2043 | | - " print(\"Method: PMI (default) – Highlights statistically significant word associations using raw PMI scores\")\n", |
| 2043 | + " print(\"Method: PMI (default) – Highlights statistically significant word associations using positive PMI (PPMI) scores\")\n", |
2044 | 2044 | " elif input_data.clustering_method == 4:\n", |
2045 | 2045 | " if input_data.distance_metric == \"raw_weighted\":\n", |
2046 | 2046 | " print(\"Method: TF-IDF (raw weighted) – Uses raw TF-IDF-weighted co-occurrence scores for word associations\")\n", |
|
2605 | 2605 | " use_custom_stoplist = True\n", |
2606 | 2606 | "\n", |
2607 | 2607 | " # Core Analysis\n", |
2608 | | - " clustering_method = 3 # 1 = RoBERTa, 2 = Jaccard, 3 = PMI, 4 = TF-IDF\n", |
| 2608 | + " clustering_method = 3 # 1 = RoBERTa, 2 = Co-occurrence, 3 = PMI, 4 = TF-IDF\n", |
2609 | 2609 | " distance_metric = \"cosine\" \n", |
2610 | 2610 | " \n", |
2611 | 2611 | "# Note on clustering method and distance metric:\n", |
|
2614 | 2614 | "# - distance_metric is always \"default\" (ignored internally)\n", |
2615 | 2615 | "# - Uses contextual embeddings directly\n", |
2616 | 2616 | "#\n", |
2617 | | - "# 2. Jaccard (clustering_method = 2)\n", |
| 2617 | + "# 2. Co-occurrence (clustering_method = 2)\n", |
2618 | 2618 | "# - \"default\": context-window overlap measured by Jaccard index\n", |
2619 | 2619 | "# (set-based, binary overlap score)\n", |
2620 | 2620 | "# - \"cosine\" : context vectors built from co-occurrence counts,\n", |
2621 | 2621 | "# compared using cosine similarity (frequency-sensitive)\n", |
2622 | 2622 | "#\n", |
2623 | 2623 | "# 3. PMI (clustering_method = 3)\n", |
2624 | | - "# - \"default\": classic PMI co-occurrence scores\n", |
| 2624 | + "# - \"default\": positive PMI (PPMI) scores (PMI supports \"cosine\" only)\n", |
2625 | 2625 | "# - \"cosine\" : PMI-weighted context vectors compared with cosine similarity\n", |
2626 | 2626 | "# (captures similarity of PMI distributions rather than raw scores)\n", |
2627 | 2627 | "#\n", |
|
3045 | 3045 | " use_custom_stoplist = True\n", |
3046 | 3046 | "\n", |
3047 | 3047 | " # Core Analysis\n", |
3048 | | - " clustering_method = 2 # 1 = RoBERTa, 2 = Jaccard, 3 = PMI, 4 = TF-IDF\n", |
| 3048 | + " clustering_method = 2 # 1 = RoBERTa, 2 = Co-occurrence, 3 = PMI, 4 = TF-IDF\n", |
3049 | 3049 | " distance_metric = \"cosine\" \n", |
3050 | 3050 | " \n", |
3051 | 3051 | " # Note on clustering method and distance metric:\n", |
|
3241 | 3241 | " - If not provided, the default list will be used.\n", |
3242 | 3242 | "\n", |
3243 | 3243 | "4. Clustering Method & Parameters:\n", |
3244 | | - " - Choose from: 1 = RoBERTa, 2 = Jaccard, 3 = PMI, 4 = TF-IDF.\n", |
| 3244 | + " - Choose from: 1 = RoBERTa, 2 = Co-occurrence, 3 = PMI, 4 = TF-IDF.\n", |
3245 | 3245 | " - For methods 2–4, specify distance metric (default or cosine) and context window size.\n", |
3246 | 3246 | "\n", |
3247 | 3247 | "5. Analysis Filters:\n", |
|
3402 | 3402 | " while True:\n", |
3403 | 3403 | " try:\n", |
3404 | 3404 | " clustering_method = int(\n", |
3405 | | - " input(\"Choose clustering method 1=RoBERTa, 2=Jaccard, 3=PMI, 4=TF-IDF [Default 1]: \").strip() or \"1\"\n", |
| 3405 | + " input(\"Choose clustering method 1=RoBERTa, 2=Co-occurrence, 3=PMI, 4=TF-IDF [Default 1]: \").strip() or \"1\"\n", |
3406 | 3406 | " )\n", |
3407 | 3407 | " if clustering_method in (1, 2, 3, 4):\n", |
3408 | 3408 | " break\n", |
|
3542 | 3542 | ], |
3543 | 3543 | "metadata": { |
3544 | 3544 | "kernelspec": { |
3545 | | - "display_name": "cmap_vis_replication", |
| 3545 | + "display_name": "Python 3", |
3546 | 3546 | "language": "python", |
3547 | | - "name": "cmap_vis_replication" |
| 3547 | + "name": "python3" |
3548 | 3548 | }, |
3549 | 3549 | "language_info": { |
3550 | 3550 | "codemirror_mode": { |
|
0 commit comments