{"id":50959227,"url":"https://github.com/djleamen/cluster-unstructured-text-data","last_synced_at":"2026-06-18T11:32:39.437Z","repository":{"id":363942113,"uuid":"1238224589","full_name":"djleamen/cluster-unstructured-text-data","owner":"djleamen","description":"Groups patterns in unstructured .txt data using classic clustering (K-Means or DBSCAN) and surfaces each cluster's top keywords and representative example documents.","archived":false,"fork":false,"pushed_at":"2026-06-11T01:27:16.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-11T03:13:48.762Z","etag":null,"topics":["clustering","dbscan","kmeans-clustering","unstructured-data"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/djleamen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-13T23:47:28.000Z","updated_at":"2026-06-11T01:27:17.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/djleamen/cluster-unstructured-text-data","commit_stats":null,"previous_names":["djleamen/cluster-unstructured-text-data"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/djleamen/cluster-unstructured-text-data","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djleamen%2Fcluster-unstructured-text-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djleamen%2Fcluster-unstructured-text-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djleamen%2Fcluster-unstructured-text-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djleamen%2Fcluster-unstructured-text-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djleamen","download_url":"https://codeload.github.com/djleamen/cluster-unstructured-text-data/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djleamen%2Fcluster-unstructured-text-data/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34489116,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clustering","dbscan","kmeans-clustering","unstructured-data"],"created_at":"2026-06-18T11:32:38.844Z","updated_at":"2026-06-18T11:32:39.423Z","avatar_url":"https://github.com/djleamen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cluster Unstructured Text Data\n\nA small platform that **groups patterns in unstructured `.txt` data** using classic\nclustering (**K-Means** or **DBSCAN**) and surfaces each cluster's top keywords and\nrepresentative example documents.\n\n```\n   .txt files ──▶ TF-IDF / embeddings ──▶ K-Means or DBSCAN\n                                                 │\n                                                 ▼\n                              cluster keywords + exemplars\n```\n\n## Features\n\n- **Flexible input** — load a single `.txt`, a directory of files, pasted text, or in-memory strings. Split by line, paragraph, or whole document.\n- **Two vectorizers** — TF-IDF (fast, no downloads) or sentence-transformer embeddings (semantic).\n- **Two clustering algorithms** — K-Means (with optional auto-K via silhouette) and DBSCAN (great for noisy data + outlier detection).\n- **Cluster summaries** — each cluster gets its top TF-IDF keywords and the documents nearest to its centroid as exemplars.\n- **Three ways to use it** — Python API, CLI, or a Streamlit web UI with an interactive 2D cluster map.\n\n## Quick start\n\n```bash\npython -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n```\n\n### CLI\n\n```bash\n# install the package so the `cluster-text` command is on PATH\npip install -e .\n\ncluster-text samples/reviews.txt --algorithm kmeans -k 3\ncluster-text samples/reviews.txt --algorithm dbscan --eps 0.9 --min-samples 2\ncluster-text samples/ --vectorizer embedding --output outputs/report.json\n```\n\n### Streamlit UI\n\n```bash\nstreamlit run app.py\n```\n\nUpload one or more `.txt` files (or paste text), pick an algorithm in the sidebar, and click **Run pipeline**. You'll get:\n\n- summary metrics (number of clusters, silhouette, noise)\n- an interactive PCA scatter plot colored by cluster\n- per-cluster cards with keywords, exemplars, and full member list\n- a CSV download of every document with its cluster id\n\n### Python API\n\n```python\nfrom cluster_text.loader import load_texts\nfrom cluster_text.pipeline import PipelineConfig, run_pipeline\n\ndocs = load_texts([\n    \"The pasta was perfectly cooked.\",\n    \"Battery life on this phone is terrible.\",\n    \"Flight was delayed three hours.\",\n    # ...\n])\n\nresult = run_pipeline(\n    docs,\n    PipelineConfig(vectorizer=\"tfidf\", algorithm=\"kmeans\", n_clusters=3),\n)\n\nfor s in result.summaries:\n    print(s.cluster_id, s.size, s.keywords[:5])\n    for ex in s.exemplars:\n        print(\"  •\", ex)\n```\n\n## Configuration knobs\n\n| Option | Where | Notes |\n| --- | --- | --- |\n| `vectorizer` | `tfidf` / `embedding` | Embeddings need `sentence-transformers` (in `requirements.txt`). |\n| `algorithm` | `kmeans` / `dbscan` | DBSCAN labels outliers as `-1`. |\n| `n_clusters` | int or `None` | `None` → silhouette-based auto-K (range configurable). |\n| `dbscan_eps`, `dbscan_min_samples`, `dbscan_metric` | DBSCAN params | Default metric is `cosine`. |\n\n## Testing\n\n```bash\npip install -e \".[dev]\"\npytest\n```\n\nThe tests run the full pipeline (TF-IDF + K-Means + DBSCAN) on a tiny built-in corpus — no network access required.\n\n## Project layout\n\n```\nsrc/cluster_text/\n  loader.py           # .txt loading + splitting\n  vectorizer.py       # TF-IDF + sentence-transformer embeddings\n  clustering.py       # K-Means, DBSCAN, auto-K via silhouette\n  summarize.py        # keywords + exemplars per cluster\n  pipeline.py         # end-to-end orchestration\n  cli.py              # `cluster-text` command\napp.py                # Streamlit UI\nsamples/reviews.txt   # tiny sample corpus\ntests/                # pytest suite\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjleamen%2Fcluster-unstructured-text-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjleamen%2Fcluster-unstructured-text-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjleamen%2Fcluster-unstructured-text-data/lists"}