{"id":20462075,"url":"https://github.com/bact/constitution","last_synced_at":"2025-05-08T22:32:24.174Z","repository":{"id":160405703,"uuid":"120137617","full_name":"bact/constitution","owner":"bact","description":"Convert Thai constitution from PDF to plaintext and correct encoding glitches","archived":true,"fork":false,"pushed_at":"2018-02-03T23:31:40.000Z","size":1810,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-06T21:55:29.355Z","etag":null,"topics":["law","open-data","pdf-conversion","thai-language"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bact.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2018-02-03T23:04:55.000Z","updated_at":"2024-12-18T16:43:20.000Z","dependencies_parsed_at":"2023-07-23T00:32:13.954Z","dependency_job_id":null,"html_url":"https://github.com/bact/constitution","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bact%2Fconstitution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bact%2Fconstitution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bact%2Fconstitution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bact%2Fconstitution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bact","download_url":"https://codeload.github.com/bact/constitution/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253158285,"owners_count":21863268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["law","open-data","pdf-conversion","thai-language"],"created_at":"2024-11-15T12:29:52.443Z","updated_at":"2025-05-08T22:32:24.163Z","avatar_url":"https://github.com/bact.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# constitution\n\nแปลงรัฐธรรมนูญ (ร่างต้นปี 2559) จาก PDF เป็น HTML\nดูคำอธิบายได้ในสไลด์ https://www.slideshare.net/arthit/pdf-plain-text และโน๊ต https://www.facebook.com/notes/10154493302702646 \n \n\nConvert Thai constitution draft (early 2016) from PDF to plaintext and correct encoding glitches. It is crafted to work with a specific set of PDF. Mainly one from https://www.parliament.go.th/ewtcommittee/ewt/draftconstitution2/download/article/article_20160129132217.pdf and following versions. Cannot be guarantted to work with other PDFs. This is like web scraping, you have to tailor it to a particular website. \n\n- Use [Apache PDFBox](https://pdfbox.apache.org/) for PDF to HTML\n  - ```java -jar pdfbox-app.jar ExtractText -html file.pdf file.html```\n  - Cannot convert directly to plaintext, as there are Thai characters in the PDF that use codepoints in Private User Area (PUA) -- all the PUAs will be discarded for conversion to plaintext\n- Convert Thai characters that encoded as HTML entities to UTF-8. The same process will also convert PUAs to valid codepoints.\n  ```python\n  pua = {\n    '63233': '\u0026#3636;', # 0xf701 Sara I\n    '63234': '\u0026#3637;', # 0xf702\n    '63235': '\u0026#3638;', # 0xf703\n    '63236': '\u0026#3639;', # 0xf704\n    '63237': '\u0026#3656;', # 0xf705\n    '63238': '\u0026#3657;', # 0xf706 Mai Tho (on Po Pla)\n    '63242': '\u0026#3656;', # 0xf70a Mai Ek\n    '63243': '\u0026#3657;', # 0xf70b Mai Tho\n    '63246': '\u0026#3660;', # 0xf70e Thantakat\n    '63248': '\u0026#3633;', # 0xf710  Mai Han Akhat (on Po Pla)\n    '63250': '\u0026#3655;', # 0xf712 Mai Tai Khu (on Po Pla)\n    '63251': '\u0026#3656;', # 0xf713\n    '63252': '\u0026#3657;'  # 0xf714\n   }\n   ```\n- Correct wrong order of Thai characters, like tonemark + vowel --\u003e vowel + tonemark\n- Basic reformatting\n\nMore explanation (in Thai): [slides](https://www.slideshare.net/arthit/pdf-plain-text), [notes](https://www.facebook.com/notes/10154493302702646)\n\nIdeally, there should be no need for a script like this. All laws should be available in search friendly and machine-readable format.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbact%2Fconstitution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbact%2Fconstitution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbact%2Fconstitution/lists"}