{"id":21397322,"url":"https://github.com/xiamx/gen_fst","last_synced_at":"2025-07-13T20:32:15.201Z","repository":{"id":37664053,"uuid":"97130505","full_name":"xiamx/gen_fst","owner":"xiamx","description":"Elixir module that implements a generic finite state transducer with customizable rules expressed in a DSL.","archived":false,"fork":false,"pushed_at":"2022-06-22T02:38:10.000Z","size":17,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-29T08:42:46.083Z","etag":null,"topics":["elixir","finite-state-machine","fst","morphological-analysis","morphology","nlp","transducer"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/xiamx.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}},"created_at":"2017-07-13T14:16:55.000Z","updated_at":"2023-01-04T15:36:30.000Z","dependencies_parsed_at":"2022-09-09T02:33:50.562Z","dependency_job_id":null,"html_url":"https://github.com/xiamx/gen_fst","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiamx%2Fgen_fst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiamx%2Fgen_fst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiamx%2Fgen_fst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiamx%2Fgen_fst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiamx","download_url":"https://codeload.github.com/xiamx/gen_fst/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225916557,"owners_count":17544821,"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":["elixir","finite-state-machine","fst","morphological-analysis","morphology","nlp","transducer"],"created_at":"2024-11-22T14:41:41.011Z","updated_at":"2025-07-13T20:32:15.193Z","avatar_url":"https://github.com/xiamx.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![Elixir](https://hexdocs.pm/ex_unit/assets/logo.png) GenFST\n\n[![Build Status](https://travis-ci.org/xiamx/gen_fst.svg?branch=master)](https://travis-ci.org/xiamx/gen_fst)\n[![Hex.pm](https://img.shields.io/hexpm/v/gen_fst.svg)](https://hex.pm/packages/gen_fst)\n[![license](https://img.shields.io/github/license/xiamx/gen_fst.svg)](https://github.com/xiamx/gen_fst/blob/master/LICENSE)\n\nGenFST implements a generic finite state transducer with\ncustomizable rules expressed in a DSL.\n\nA finite-state transducer (FST) is a finite-state machine \nwith two memory tapes, following the terminology for Turing \nmachines: an input tape and an output tape.\n\nA FST will read a set of strings on the input tape and \ngenerates a set of relations on the output tape. An FST \ncan be thought of as a translator or relater between strings in a set.\n\nIn morphological parsing, an example would be inputting a string of letters \ninto the FST, the FST would then output a string of \n[morphemes](https://en.wikipedia.org/wiki/Morphemes).\n\n## Features\n\n- **Core FST Operations**: Create and configure finite state transducers\n- **Batch Processing**: Process multiple inputs efficiently with `parse_batch/2`\n- **Parsing Utilities**: Check parsing capability with `can_parse?/2`\n- **Statistics**: Get detailed FST information with `stats/1`\n- **Comprehensive Error Handling**: Clear error messages and ambiguity detection\n- **Type Safety**: Full type specifications for all functions\n\n## Example\n\nHere we implement a simple morphological parser for English language. This\nmorphological parser recognizes different inflectional morphology of the verbs.\n\n```elixir\nfst = GenFST.new\n|\u003e GenFST.rule([\"play\", {\"s\", \"^s\"}])\n|\u003e GenFST.rule([\"act\", {\"s\", \"^s\"}])\n|\u003e GenFST.rule([\"act\", {\"ed\", \"^ed\"}])\n|\u003e GenFST.rule([\"act\", {\"ing\", \"\"}])\n\n# Single parsing\n{:ok, \"play^s\"} = GenFST.parse(fst, \"plays\")\n\n# Batch processing\nresults = GenFST.parse_batch(fst, [\"plays\", \"acted\", \"invalid\"])\n# [{:ok, \"play^s\"}, {:ok, \"act^ed\"}, {:error, \"not possible\"}]\n\n# Check parsing capability\ntrue = GenFST.can_parse?(fst, \"plays\")\nfalse = GenFST.can_parse?(fst, \"invalid\")\n\n# Get FST statistics\n%{vertex_count: 12, edge_count: 11, terminal_vertices: 4} = GenFST.stats(fst)\n```\n\nFor example if we pass the third-person singular tense of the verb _act_,\n`GenFST.parse(fst, \"acts\")`, the morphological parser will output\n`{:ok, \"act^s\"}`. The semantic of rule definition is given at [`rule/2`](https://hexdocs.pm/gen_fst/GenFST.html#rule/2).\n\n## Return Types\n\nGenFST v0.5.0 uses explicit tagged tuples for better error handling:\n\n- `{:ok, result}` - Successful parsing with single result\n- `{:ambiguous, [results]}` - Multiple valid parsings found  \n- `{:error, reason}` - Parsing failed\n\n## Installation\n\nThe package can be installed by adding `gen_fst` to your list of \ndependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:gen_fst, \"~\u003e 0.5.0\"}]\nend\n```\n\n## Documentation\n\nThe docs for this project can be found at [https://hexdocs.pm/gen_fst](https://hexdocs.pm/gen_fst).\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md) for detailed release notes.\n\n## What's New in v0.5.0\n\n- 🚀 **New Functions**: `parse_batch/2`, `can_parse?/2`, `stats/1`\n- 🔧 **Better Error Handling**: Explicit tagged tuple returns\n- 📊 **Enhanced Testing**: 14 comprehensive test cases\n- 🛠️ **Developer Tools**: Credo, Dialyxir, formatter configuration\n- 📚 **Improved Documentation**: Complete type specs and examples\n- ⚡ **Modernized Dependencies**: Updated to latest versions\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiamx%2Fgen_fst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiamx%2Fgen_fst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiamx%2Fgen_fst/lists"}