{"id":50736352,"url":"https://github.com/leuc/acp-127","last_synced_at":"2026-06-10T14:01:06.446Z","repository":{"id":361412937,"uuid":"1254258350","full_name":"leuc/ACP-127","owner":"leuc","description":"Allied Communications Publications 127g \"TAPE RELAY PROCEDURES\" for the Central Foreign Policy Files, 1973-1979, Released Telegrams, Record Group 59: General Records of the Department of State, National Archives","archived":false,"fork":false,"pushed_at":"2026-05-30T13:59:54.000Z","size":143,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-30T15:20:22.782Z","etag":null,"topics":["cablegate","cfpf","data-science","diplomatic-cables"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leuc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-05-30T10:43:43.000Z","updated_at":"2026-05-30T13:59:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/leuc/ACP-127","commit_stats":null,"previous_names":["leuc/acp-127"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/leuc/ACP-127","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leuc%2FACP-127","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leuc%2FACP-127/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leuc%2FACP-127/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leuc%2FACP-127/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leuc","download_url":"https://codeload.github.com/leuc/ACP-127/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leuc%2FACP-127/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34155422,"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-10T02:00:07.152Z","response_time":89,"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":["cablegate","cfpf","data-science","diplomatic-cables"],"created_at":"2026-06-10T14:01:05.509Z","updated_at":"2026-06-10T14:01:06.431Z","avatar_url":"https://github.com/leuc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"A Python rebulk parser for Allied Communications Publications (ACPs) 127 (G),\n\"TAPE RELAY PROCEDURES\" Telegrams from the Central Foreign Policy Files,\n1973-1779, Released Telegrams.\nRecord Group 59: General Records of the Department of State, National Archives.\n\n# Data Source:\n\n```\nhttps://archive.org/download/U.s.DiplomaticCablesYear1973/us-diplomatic-cables-txt-1973.7z\nhttps://archive.org/download/U.s.DiplomaticCablesYear1974/us-diplomatic-cables-txt-1974.7z\nhttps://archive.org/download/U.s.DiplomaticCablesYear1975/us-diplomatic-cables-txt-1975.7z\nhttps://archive.org/download/U.s.DiplomaticCablesYear1976/us-diplomatic-cables-txt-1976.7z\nhttps://archive.org/download/U.s.DiplomaticCablesYear1977/us-diplomatic-cables-txt-1977.7z\nhttps://archive.org/download/U.s.DiplomaticCablesYear1978/us-diplomatic-cables-txt-1978.7z\nhttps://archive.org/download/U.s.DiplomaticCablesYear1979/us-diplomatic-cables-txt-1979.7z\n```\n\n# Installation\n\n## Ubuntu Dependencies\n\n```bash\nsudo apt-get update\nsudo apt-get install python3-orjson python3-rebulk\n```\n\n## Using pip (alternative or supplement)\n\n```bash\npip install -r requirements.txt\n```\n\n# Downloading and Extracting Data\n\n```bash\n# Create a directory for the data\nmkdir -p cables\ncd cables\n\n# Download and extract each year (1973-1979)\nfor year in {1973..1979}; do\n    echo \"Downloading $year...\"\n    curl -LO \"https://archive.org/download/U.s.DiplomaticCablesYear$year/us-diplomatic-cables-txt-$year.7z\"\n    echo \"Extracting $year...\"\n    7z x us-diplomatic-cables-txt-$year.7z\n    # Optional: remove the archive to save space\n    rm us-diplomatic-cables-txt-$year.7z\ndone\n```\n\n# Usage\n\n## Basic Usage\n\nProcess all .txt and .tel files in a directory (recursively):\n\n```bash\npython3 -m src.extractor cables/\n```\n\n## With Limits\n\nLimit the number of files processed (useful for testing):\n\n```bash\npython3 -m src.extractor cables/ --limit 100\n```\n\n## Random Sampling\n\nProcess a random sample of files (overrides --limit if both are given):\n\n```bash\npython3 -m src.extractor cables/ --sample 1000\n```\n\n## Output Format\n\n- **STDOUT**: Each processed file's extraction result is output as a separate JSON line (streaming)\n- **STDERR**: Progress messages and final coverage statistics (as a JSON object)\n\nExample of processing a single file and viewing the output:\n\n```bash\n# Process one file, capture stdout and stderr separately\npython3 -m src.extractor cables/1973/01/1973LIMA00001.txt 2\u003ecoverage.json \u003eresult.json\n\n# View the extraction result\ncat result.json | jq .\n\n# View the coverage statistics\ncat coverage.json | jq .\n```\n\n## Batch Processing (Multiple Years)\n\nThe script uses multiprocessing internally (`ProcessPoolExecutor`), so a simple sequential loop is all that's needed:\n\n```bash\nmkdir -p results\nfor year in {1973..1979}; do\n    echo \"Processing $year ...\"\n    python3 -m src.extractor cables/$year/ 2\u003eresults/$year-coverage.json \u003eresults/$year-results.ndjson\n    count=$(wc -l \u003c \"results/$year-results.ndjson\")\n    echo \"Finished $year: $count records\"\ndone\n```\n\n# Reference Normalization Pipeline\n\nExtract structured reference data from ACP-127 messages and build a directed reference graph for network analysis.\n\n## Pipeline\n\n```bash\n# 1. Extract structured JSON from ACP-127 messages\npython3 -m src.extractor \u003cpaths...\u003e\n\n# 2. Flatten to reftel NDJSON (extract relevant fields for faster loading)\nfor year in {1973..1979}; do\n  jq -Mc '{\"references\": ._reference, \"attr_reference\": .\"Message Attributes\".\"Reference\",\n           \"document_number\": .\"Message Attributes\".\"Document Number\",\n           \"date\": .\"Message Attributes\".\"Draft Date\" // .\"Message Attributes\".\"Sent Date\",\n           \"message_preview\": (._message_content | if . then split(\"\\n\")[:100] | join(\"\\n\") else null end)}' \\\n    ${year}.ndjson \u003e ${year}.reftel.ndjson\ndone\n\n# 3. Normalize references to canonical MRN format\npython3 -m src.reftel_normalize *.reftel.ndjson \u003e all-mrns.ndjson\n\n# 4. Build reference graph (GraphML)\npython3 src/reftel2graph.py all-mrns.ndjson reference-graph.graphml\n\n# 5. Analyze graph connectivity\npython3 src/analyze_graph.py reference-graph.graphml\n```\n\n## Key Files\n\n| File | Description |\n|---|---|\n| `src/reftel_normalize.py` | Reference normalizer: rebulk functional pattern, O(1) station dict |\n| `src/reftel2graph.py` | GraphML builder from normalized NDJSON |\n| `src/analyze_graph.py` | Graph analysis: WCC, k-core, PageRank, communities |\n| `src/station_data.py` | 558 canonical stations + 686 variant mappings |\n\nSee `AGENTS.md` and `docs/REFTEL.md` for detailed architecture and failure analysis.\n\n# LICENSE\n\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-white.svg)](https://www.gnu.org/licenses/gpl-3.0)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleuc%2Facp-127","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleuc%2Facp-127","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleuc%2Facp-127/lists"}