{"id":20657375,"url":"https://github.com/epfl-systemf/specmerger","last_synced_at":"2025-10-26T04:03:18.428Z","repository":{"id":253251244,"uuid":"842937313","full_name":"epfl-systemf/SpecMerger","owner":"epfl-systemf","description":"Conformance Checker for Specifications","archived":false,"fork":false,"pushed_at":"2024-08-23T13:58:24.000Z","size":239,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-17T11:31:20.403Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/epfl-systemf.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}},"created_at":"2024-08-15T12:35:46.000Z","updated_at":"2024-08-23T13:58:28.000Z","dependencies_parsed_at":"2024-11-16T18:33:19.121Z","dependency_job_id":null,"html_url":"https://github.com/epfl-systemf/SpecMerger","commit_stats":null,"previous_names":["epfl-systemf/specmerger"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epfl-systemf%2FSpecMerger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epfl-systemf%2FSpecMerger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epfl-systemf%2FSpecMerger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epfl-systemf%2FSpecMerger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epfl-systemf","download_url":"https://codeload.github.com/epfl-systemf/SpecMerger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242768072,"owners_count":20182098,"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":[],"created_at":"2024-11-16T18:20:23.396Z","updated_at":"2025-10-26T04:03:18.359Z","avatar_url":"https://github.com/epfl-systemf.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SpecMerger\n\nThis tool was developped in the Systems and Formalism Lab at EPFL.\n\nFor a full understanding of the project, please read this [blogpost](https://systemf.epfl.ch/blog/SpecMerger) that explains it in great details.\n\nThis tool can be used to compare two trees that were constructed with special Nodes provided in the project.\n\nThis can be very useful to compare two structured documents that should have the same content, like for example\na specification and its implementation (by having the specification text in comments on top of actual lines of code) or \nif you just have two different data formats that need to have the same content.\n\nTo use this tool, you will first need to write a Parser to generate a `ParsedPage` for each document.\nAfter this you can use the following code to see a nice comparison in the form of an HTML document.\n\n```python\nfrom spec_merger.aligner import Aligner\nfrom spec_merger.html_renderer import HTMLRenderer\nimport webbrowser, os\n# p1 is ParsedPage n°1, p2 is n°2\naligner = Aligner()\nresult = aligner.align(p1,p2)\nrendered = HTMLRenderer(result).render(path_to_template=\"spec_merger\")\nwith open(\"comparison.html\", \"w+\") as f:\n    f.write(rendered)\nwebbrowser.open(f\"file://{os.path.abspath('comparison.html')}\", 2)\n```\n\n## Type of nodes in the tree\nThe diferent existing nodes can all be found in the content_classes folder, which are :\n- String\n- Dictionary\n- OrderedDictionary\n- Bag (a set)\n- OrderedSeq (a list)\n- WildCard (matches anything)\n\nIf you need to create another type of node, just create a new class in the folder by inspiring yourself of the other ones.\n\nWhenever you instantiate the aligner, you can pass it a dictionary that takes a pair of types and returns a function of type `Content,Content -\u003e Content`.\nThis function will then be called whenever the tool needs to compare two nodes that have the correct types.\n\nHere is an example:\n```python\nfrom spec_merger.content_classes.dictionary import Dictionary\nfrom spec_merger.content_classes.string import String\nfrom spec_merger.content_classes.misalignment import Misalignment\nfrom spec_merger.aligner_utils import ReportErrorType\nfrom spec_merger.aligner import Aligner\n\nfn_map = {(Dictionary, String): lambda dic,str: Misalignment((dic.position,str.position),dic,str,ReportErrorType.MISMATCHED_TYPES)}\naligner = Aligner(fn_map)\n# Now aligner will call this specific function whenever it is comparing a Dictionary and a String\n```\n\nIf you wish to have a type that has very special behaviour, like the WildCard, you can modify the `special comparator` function, to do whatever behaviour you want.\nNote however that this function will only be called if the pair of types was not found in the function_map.\n\n## Example\nYou can have a look at the test-example folder, it contains a very minimal example for a specification vs implementation\ncheck and try to spot the implementation mistakes ;)\n\nIf you want to have a look at a bigger project where it was used, have a look at [Warblre](https://github.com/epfl-systemf/Warblre).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepfl-systemf%2Fspecmerger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepfl-systemf%2Fspecmerger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepfl-systemf%2Fspecmerger/lists"}