{"id":13558078,"url":"https://github.com/Inventitech/strans","last_synced_at":"2025-04-03T12:31:44.394Z","repository":{"id":140901634,"uuid":"169402363","full_name":"Inventitech/strans","owner":"Inventitech","description":"Performs string manipulation tasks by learning from the provided example(s), instead of having to program them out explicitly.","archived":false,"fork":false,"pushed_at":"2020-05-13T13:13:59.000Z","size":844,"stargazers_count":547,"open_issues_count":3,"forks_count":17,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-04T08:37:15.298Z","etag":null,"topics":["program-synthesis","sed","shell","unix-cli","unix-command"],"latest_commit_sha":null,"homepage":null,"language":"Roff","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/Inventitech.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}},"created_at":"2019-02-06T12:26:22.000Z","updated_at":"2024-10-26T06:36:25.000Z","dependencies_parsed_at":"2023-05-15T08:45:45.832Z","dependency_job_id":null,"html_url":"https://github.com/Inventitech/strans","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Inventitech%2Fstrans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Inventitech%2Fstrans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Inventitech%2Fstrans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Inventitech%2Fstrans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Inventitech","download_url":"https://codeload.github.com/Inventitech/strans/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247002450,"owners_count":20867464,"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":["program-synthesis","sed","shell","unix-cli","unix-command"],"created_at":"2024-08-01T12:04:44.012Z","updated_at":"2025-04-03T12:31:39.384Z","avatar_url":"https://github.com/Inventitech.png","language":"Roff","readme":"strans\n======\n\n[![Build Status](https://travis-ci.com/Inventitech/strans.svg?token=1pPnTvKwseJq7cTLeeFE\u0026branch=master)](https://travis-ci.com/Inventitech/strans)\n![LOC](https://tokei.rs/b1/github/inventitech/strans)\n[![Github Releases](https://img.shields.io/github/downloads/inventitech/strans/total.svg)](https://github.com/Inventitech/strans/releases)\n[![Join the chat at https://gitter.im/inventitech/strans](https://badges.gitter.im/inventitech/strans.svg)](https://gitter.im/inventitech/strans?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n\n`strans` (string transform) is an intuitive string manipulation\nutility for the shell (primarily Unix, but should work™\ncross-platform). Users do not need to know anything about\nprogramming. All they need to do is provide `strans` with a set of\nexamples. `strans` will automagically learn transformation rules from\nthese examples and apply them to the input given on STDIN.\n\nHow to install\n==============\n\n`strans` is distributed platform indepedently as a NuGet package, or\n(if you do not want to install dotnet) standalone as an AppImage for\nLinux and as a DMG for MacOs.  Download the latest `strans` from\n[releases](https://github.com/Inventitech/strans/releases).\n\n## Platform-independent global tool (requires `dotnet`)\n\n`strans` is available as a \n[global tool on NuGet](https://www.nuget.org/packages/strans). If you \nhave `dotnet` installed, you can simply `dotnet tool install -g strans` \nto install it (or use `dotnet tool update`, `uninstall` etc.).\n\n## Linux\n\nOur AppImage should run on practically any recent linux Desktop\ndistribution.\n\nAfter downloading, simply do\n\n`\nchmod +x strans-linux.AppImage\n./strans-linux.AppImage\n`\n\nTo install it system-wide as `strans`, just\n\n`sudo cp strans-linux.AppImage /usr/bin/strans`\n\n## MacOs\nAfter mounting the `dmg` and copying `strans.app` into `/Applications`, it might be necessary to\n\n```\nchmod +x /Applications/strans.app/Contents/MacOS/strans\n/Applications/strans.app/Contents/MacOS/strans\n```\nto run `strans`.\n \n\nHow to use\n==========\n```\n# With before and after example\nstrans -b pattern-to-match -a desired-transformation\n\n# With file that contains examples\nstrans -f file-with-examples\n\n# Help page\nstrans --help\n```\n\nExamples\n========\n![Strans in action](https://github.com/Inventitech/strans/raw/master/strans.gif)\n\n## Example 1: Extract ending of files\n\nAssume that\n\n```\nls\nDocument.pdf  Document2.pdf Document.txt  Document.png\n```\n\nNow we want to get a unique list of all file endings present in the directory:\n\n```\nls | strans -b Document.pdf -a pdf | sort -u\n```\n\nNote how nicely strans (here defined as an alias) integrates with other tools.\n\nOf course, as\n[StackOverflow](https://stackoverflow.com/questions/1842254/how-can-i-find-all-of-the-distinct-file-extensions-in-a-folder-hierarchy)\nwill tell you, we could obtain the same result with\n\n```\nls | perl -ne 'print $1 if m/\\.([^.\\/]+)$/' | sort -u \n```\n\nBut with `strans` we accomplished the same with much less brain work,\nwithout StackOverflow and Perl, but instead with pure joy!\n\n## Example 2: Convert full names to their initials\n\n```\nprintf \"Moritz Beller\\nGeorgios Gousios\" |\nstrans -b \"First Last\" -a \"FL\"\n```\n\nneatly outputs\n\n```\nMB\nGG\n```\n\nHowever, when we add a third entry with a middle name, Andy Emil\nZaidman, things start to break, as this does not appear in the\ninitials:\n\n```\nMB\nGG\nAZ\n```\n\nWe can fix this by providing `strans` with another example. We create\na file called `example-transformations`\n\n```\nFirst Last =\u003e FL\nFirstname Middlename Lastname =\u003e FML\n```\n\nand call\n\n```\nprintf \"Moritz Beller\\nGeorgios Gousios\\nAndy Emil Zaidman\" |\nstrans --example-file example-transformations\n```\n\nAnd, voila, the output is\n\n```\nMB\nGG\nAEZ\n```\n\nNote how `strans` adds the second example and generates a global\ntransformation rule that satisfies all examples given to it. Simply\nhaving the last FML example would not be enough because it would miss\nthe case where only two names are available.\n\nHow to develop\n==============\n\nYou need [dotnet](https://dotnet.microsoft.com/) to run `strans`.\n\n```\ngit clone https://github.com/Inventitech/strans.git\ncd strans\ndotnet restore\ndotnet publish -c Release\n```\n\nAn alias (in your bashrc, ...) can make `strans` integrate seamlessly in\na Unix environment:\n\n```\nalias strans=\"dotnet path/to/strans.dll\"\n```\n\n\nBackground\n==========\n\n`strans` uses program-by-example techniques from [Microsoft\nPROSE](https://microsoft.github.io/prose/) to come up with the rules\nbehind this string manipulation. PROSE allows the creation of\nextremely complex string transformations within a matter of a few\nseconds by just giving easy-to-write examples. In its essence,\n`strans` is only a light-weight wrapper around and direct application\nof Microsoft's PROSE framework. `strans` provides the goodness of the\nnow-removed PowerShell (!) command\n[Convert-String](https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Utility/Convert-String?view=powershell-5.1).\n","funding_links":[],"categories":["Roff","shell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInventitech%2Fstrans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FInventitech%2Fstrans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInventitech%2Fstrans/lists"}