{"id":17524095,"url":"https://github.com/recap-utr/arguebuf-python","last_synced_at":"2025-04-23T17:22:33.793Z","repository":{"id":40691227,"uuid":"224925689","full_name":"recap-utr/arguebuf-python","owner":"recap-utr","description":"Create and analyze argument graphs and serialize them via Protobuf","archived":false,"fork":false,"pushed_at":"2025-04-21T03:37:16.000Z","size":1607,"stargazers_count":9,"open_issues_count":2,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-21T04:44:14.582Z","etag":null,"topics":["aif","argumentation","cli","graph","grpc","protobuf","python"],"latest_commit_sha":null,"homepage":"https://arguebuf.readthedocs.io/en/latest/","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/recap-utr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-11-29T21:42:14.000Z","updated_at":"2025-04-14T07:29:53.000Z","dependencies_parsed_at":"2023-10-03T13:37:22.581Z","dependency_job_id":"afc0a330-c57f-4977-8593-50f03b627422","html_url":"https://github.com/recap-utr/arguebuf-python","commit_stats":{"total_commits":277,"total_committers":13,"mean_commits":"21.307692307692307","dds":0.3898916967509025,"last_synced_commit":"666240fc35ae9ff7d6a9d20fddab36361d13ce6f"},"previous_names":["recap-utr/argument-graph"],"tags_count":69,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recap-utr%2Farguebuf-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recap-utr%2Farguebuf-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recap-utr%2Farguebuf-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recap-utr%2Farguebuf-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/recap-utr","download_url":"https://codeload.github.com/recap-utr/arguebuf-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250000285,"owners_count":21358811,"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":["aif","argumentation","cli","graph","grpc","protobuf","python"],"created_at":"2024-10-20T14:06:26.890Z","updated_at":"2025-04-23T17:22:33.774Z","avatar_url":"https://github.com/recap-utr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Arguebuf Python\n\nArguebuf is a format for serializing argument graphs and specified using Protobuf.\nThe complete specification and documentation is available at the [Buf Schema Registry](https://buf.build/recap/arg-services/docs/main:arg_services.graph.v1).\nWhile Protobuf automatically generates native code for all major programming languages (including Python), we created a custom implementation that provides some additional benefits, including:\n\n- The ability to import existing formats like [AIF](http://www.argumentinterchange.org), [SADFace](https://github.com/Open-Argumentation/SADFace), and a few others.\n- Export of Arguebuf graphs to AIF, [NetworkX](https://networkx.org), and [Graphviz](https://graphviz.org).\n- Integration with the popular NLP library [spaCy](http://spacy.io).\n- Various helper methods to programmatically manipulate/create argument graphs.\n- More pythonic interfaces than the regular code generated by `protoc`.\n\nYou can easily install the library from [PyPI](https://pypi.org/project/arguebuf/) using pip. The documentation is hosted on [ReadTheDocs](https://arguebuf.readthedocs.io/en/latest/)\n\n## Command Line Interface (CLI)\n\nWe also offer some tools to simplify dealing with structured argument graphs.\nAmong others, it is possible to convert graphs between different formats, translate them, and render images using graphviz.\nTo use it, install the `cli` extras when installing the package.\nWhen using `pip`, this can be accomplished with\n\n`pip install arguebuf[cli]`\n\nAfterwards, you can execute it by calling `arguebuf`, for example:\n\n`arguebuf --help`\n\nAlternatively, you can use the Docker image available at `ghcr.io/recap-utr/arguebuf-python`.\nTo use it, mount a folder to the container and pass the options as the command.\n\n`docker run --rm -it -v $(pwd)/data:/data ghcr.io/recap-utr/arguebuf-python:latest --help`\n\nIf you use the `nix` package manager, you can run it as follows:\n\n`nix run github:recap-utr/arguebuf-python -- --help`\n\n## Theoretical Foundations\n\nAn argument graph is way to represent _structured_ argumentation.\nWhat sets it apart from _unstructured_ argumentation (e.g., in newspaper articles) is that only the essential/argumentative parts of a text art part of this representation.\nThese _units_ of argumentation are also called ADUs (argumentative discourse units).\nThe length of ADUs can differ dramatically (depending on various factors like the context), meaning they might contain only a few words, a sentence, or even a whole paragraph.\nThe structure of an argument is then represented through _relations_ between these units.\nFor this purpose, they can be further subdivided into _claims_ and _premises_:\nA claim is a statement that is supported or attacked by one or multiple premises.\nAt the same time, a claim may also function as a premise for another claim, making it possible to construct even complex _argument graphs_.\nOne of the claims is called _major claim_ and represents the overall claim of the whole argument.\nIn many cases (but not all), this major claim is located right at the top of the graph\nHere is a rather simple example.\n\n![Exemplary argument graph](./assets/programmatic.png)\n\nClaims, premises and the major claim are represented as _atom nodes_ while relations between them are represented by _scheme nodes_.\nThe set of nodes $V = A \\cup S$ is composed of the set of atom nodes $A$ and the set of scheme nodes $S$.\nThe supporting or attacking relations are encoded in a set of edges $E \\subseteq V \\times V \\setminus A \\times A$.\nEdges can be drawn between any type of nodes except for two atom nodes.\nFor instance, it is possible to connect two scheme nodes to support or attack the _inference_ between two ADUs.\nBased on this, we define an argument graph $G$ as the triple $G = ( V , E , M )$.\n\n## User Guide\n\nWhen importing this library, we recommend using an abbreviation such as `ag` (for _argument graph_).\n\n```python\nimport arguebuf as ag\n```\n\nIn the following, we will introduce the most important features of `arguebuf`.\nFor more details including examples, check out our API documentation.\n\n### Importing an Existing Graph\n\nWe support multiple established formats to represent argument graphs: `AIF`, `OVA`, `SADFace`, `ArgDown`, `BRAT`, and `Kialo`.\nGiven an input file, the library can automatically determine the correct format and convert it to a representation in the `arguebuf` format.\nOne can either pass a string pointing to the file or a `pathlib.Path` object.\n\n```python\ngraph = ag.load.file(\"graph.json\")\n```\n\nIt is also possible to load multiple graphs within a folder.\nHere, you need to pass the folder along with a [glob pattern](https://docs.python.org/3/library/fnmatch.html#module-fnmatch) for selecting the argument graphs.\nThis also enables to recursively load all argument graphs from a common parent directory.\n\n```python\ngraphs = ag.load.folder(\"./data\", \"**/*.json\")\n```\n\nSince atom nodes contain textual information that may need to be analyzed using NLP techniques, we support passing a custom `nlp` function to these loader methods.\nThis also makes it really easy to integrate the popular [`spacy` library](http://spacy.io) with `arguebuf` as all texts of atom nodes are automatically converted to a spacy `Doc`.\n\n```python\nimport spacy\nnlp = spacy.load(\"en_core_web_lg\")\ngraph = ag.load.file(\"graph.json\", nlp=nlp)\n```\n\n### Programmatically Create a New Graph\n\nInstead of importing an existing graph, you can also create a new one using an object-oriented API using our library.\nTo illustrate this, we generate a graph with two premises that are connected to a major claim.\n**Please note:** In case edges with nodes not yet contained in the graph are added, the respective nodes are added automatically.\n\n```python\ngraph = ag.Graph()\n\npremise1 = ag.AtomNode(\"Text of premise 1\")\npremise2 = ag.AtomNode(\"Text of premise 2\")\nclaim = ag.AtomNode(\"Text of claim\")\n\nscheme1 = ag.SchemeNode(ag.Support.DEFAULT)\nscheme2 = ag.SchemeNode(ag.Attack.DEFAULT)\n\ngraph.add_edge(ag.Edge(premise1, scheme1))\ngraph.add_edge(ag.Edge(scheme1, claim))\ngraph.add_edge(ag.Edge(premise2, scheme2))\ngraph.add_edge(ag.Edge(scheme2, claim))\n\ngraph.major_claim = claim\ngv_graph = ag.dump.graphviz(graph)\nag.render.graphviz(gv_graph, \"./assets/programmatic.png\")\n```\n\nWith this code, we get the following output\n\n![Output of programmatic graph creation](./assets/programmatic.png)\n\n### Exporting Argument Graphs\n\nWe support different output formats and integration with other libraries to ease the use of argument graphs.\nHave a look at the following code snippet to get an overview of the possibilities\n\n```python\n# Export to graphviz DOT format\ndot = ag.dump.graphviz(graph)\n\n# Export an image of this dot source to a file\nag.render.graphviz(dot, \"./graph.pdf\")\n\n# Convert to NetworkX graph\nnx = ag.dump.networkx(graph)\n\n# Save the graph as Arguebuf\nag.dump.file(graph, \"./graph.json\")\n\n# Save the graph as AIF\nag.dump.file(graph, \"./graph.json\", ag.GraphFormat.AIF)\n```\n\n## Development\n\nTo pull the testing data, make sure to install [DVC](https://dvc.org/doc/install) and run `dvc pull` in the root directory of the repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecap-utr%2Farguebuf-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frecap-utr%2Farguebuf-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecap-utr%2Farguebuf-python/lists"}