{"id":24926825,"url":"https://github.com/jaytwolab/nl_to_uml","last_synced_at":"2025-10-08T23:18:54.683Z","repository":{"id":270162277,"uuid":"891382401","full_name":"JayTwoLab/nl_to_uml","owner":"JayTwoLab","description":"[ChatGPT] Generating UML from Natural Language :kr: 자연어로 UML 생성","archived":false,"fork":false,"pushed_at":"2024-12-31T07:46:36.000Z","size":99,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T23:18:53.429Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JayTwoLab.png","metadata":{"files":{"readme":"README.ENG.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,"zenodo":null}},"created_at":"2024-11-20T08:33:53.000Z","updated_at":"2024-12-31T07:49:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"84c9dd9d-55b3-4908-96d5-c0691c651165","html_url":"https://github.com/JayTwoLab/nl_to_uml","commit_stats":null,"previous_names":["jaytwolab/nl_to_uml"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/JayTwoLab/nl_to_uml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JayTwoLab%2Fnl_to_uml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JayTwoLab%2Fnl_to_uml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JayTwoLab%2Fnl_to_uml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JayTwoLab%2Fnl_to_uml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JayTwoLab","download_url":"https://codeload.github.com/JayTwoLab/nl_to_uml/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JayTwoLab%2Fnl_to_uml/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000727,"owners_count":26082862,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"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":[],"created_at":"2025-02-02T12:53:26.869Z","updated_at":"2025-10-08T23:18:54.662Z","avatar_url":"https://github.com/JayTwoLab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## `nl_to_uml` : Automatically Generating UML from Natural Language using ChatGPT\r\n\r\n\u003e [English](README.ENG.md), [Korean](README.md)\r\n\r\n- **Natural language** text files are read, and a corresponding **UML** file is **generated**.\r\n   - Mapping information file: `mapping.json`\r\n      ```\r\n      {\r\n         \"input1.txt\": \"output1.puml\"\r\n      }\r\n      ```\r\n      - `input1.txt`: A natural language text file (description of UML)\r\n      - `output1.puml`: UML file name\r\n- Install the OpenAI library before running the Python file.\r\n  ```\r\n  pip install openai\r\n  ```\r\n\r\n\u003cbr /\u003e\r\n\r\n### Python Code\r\n\r\n\u003e nl_to_uml.py\r\n\r\n```python\r\nif __name__ == \"__main__\":\r\n    # Read API key from environment variable\r\n    # Set the environment variable 'OPENAI_API_KEY' with your OpenAI project API key\r\n    openai.api_key = os.getenv(\"OPENAI_API_KEY\")\r\n\r\n    # Check if the key is properly set (optional)\r\n    if not openai.api_key:\r\n        raise ValueError(\"OPENAI_API_KEY environment variable is not set.\")\r\n\r\n    # Enter the mapping file name\r\n    mapping_file = input(\"Enter the mapping file name (e.g., mapping.json): \")\r\n    # mapping_file = 'mapping.json'\r\n    \r\n    # Process the mapping file\r\n    process_mapping_file(mapping_file)\r\n\r\n```\r\n\r\n\u003cbr /\u003e\r\n\r\n### Functionality Overview\r\n\r\n1. **Input `mapping.json` File**:\r\n   - The user inputs the mapping file name.\r\n   - The mapping file contains 1:1 mapping information between natural language text files and PlantUML files.\r\n   - Example:\r\n     ```json\r\n     {\r\n        \"input1.txt\": \"output1.puml\",\r\n        \"input2.txt\": \"output2.puml\"\r\n     }\r\n     ```\r\n\r\n2. **Read Natural Language Text File**:\r\n   - Reads each mapped natural language text file and extracts its content.\r\n\r\n3. **Generate PlantUML Code**:\r\n   - Calls the OpenAI API to convert natural language to PlantUML code.\r\n\r\n4. **Save as PlantUML File**:\r\n   - Saves the converted code with the mapped file name.\r\n\r\n\u003cbr /\u003e\r\n\r\n### Example Execution\r\n\r\n#### 1. Create Input File: `mapping.json`\r\n\r\n\u003e You can name the JSON file as desired.\r\n\r\n```json\r\n{\r\n    \"input1.txt\": \"output1.puml\",\r\n    \"input2.txt\": \"output2.puml\"\r\n}\r\n```\r\n\r\n#### 2. Run the Program\r\n\r\n```\r\npython nl_to_uml.py\r\nEnter the mapping file name (e.g., mapping.json): mapping.json\r\n```\r\n\r\n\u003e If the source code does not take arguments, modify the comments to use it.\r\n\r\n#### 3. Output Files (`*.puml`) Created\r\n\r\n```\r\nProcessing: input1.txt -\u003e output1.puml\r\nSaved as PlantUML file: output1.puml\r\nProcessing: input2.txt -\u003e output2.puml\r\nSaved as PlantUML file: output2.puml\r\n```\r\n\r\n---\r\n\r\n#### Example 1: `input1.txt`\r\n\r\n```\r\nGenerate a class diagram.\r\n\r\nThe Teacher class includes a name and a subject, and contains setSubject and getSubject methods.\r\n```\r\n\r\n#### Example 1 Output: `output1.puml`\r\n\r\n```plantuml\r\n@startuml\r\nclass Teacher {\r\n  - String name\r\n  - String subject\r\n  + setSubject(String subject)\r\n  + getSubject(): String\r\n}\r\n@enduml\r\n```\r\n\r\n![](output1.svg)\r\n\r\n\u003e UML images are not automatically generated. Use a library or program that converts PlantUML syntax (e.g., StarUML) to an image.\r\n\r\n---\r\n\r\n#### Example 2: `input2.txt`\r\n\r\n```\r\nGenerate a use case diagram.\r\n\r\nStudents log in to register for courses and view subjects.\r\nProfessors log in to view enrolled students.\r\nStaff log in to view subjects and register classes.\r\n```\r\n\r\n#### Example 2 Output: `output2.puml`\r\n\r\n```plantuml\r\n@startuml\r\nleft to right direction\r\nactor Student\r\nactor Professor\r\nactor Staff\r\n\r\nusecase \"Register for Courses\"\r\nusecase \"View Subjects\"\r\nusecase \"View Enrolled Students\"\r\nusecase \"Register Classes\"\r\n\r\nStudent --\u003e \"Register for Courses\" : Login\r\nStudent --\u003e \"View Subjects\" : Login\r\nProfessor --\u003e \"View Enrolled Students\" : Login\r\nStaff --\u003e \"View Subjects\" : Login\r\nStaff --\u003e \"Register Classes\" : Login\r\n@enduml\r\n```\r\n\r\n![](output2.svg)\r\n\r\n---\r\n\r\n### Notes\r\n\r\n1. The `mapping.json` file must comply with the JSON format.\r\n2. Ensure that text files and PlantUML files are stored in the same directory.\r\n3. The OpenAI API key must be configured (replace `YOUR_API_KEY` with your key).\r\n\r\n### License\r\n- MIT License\r\n- See https://github.com/j2doll/nl_to_uml for more information.\r\n  \r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaytwolab%2Fnl_to_uml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaytwolab%2Fnl_to_uml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaytwolab%2Fnl_to_uml/lists"}