# kfst-rs
kfst-rs is both the optional acceleration back end of [kfst](https://github.com/fergusq/fst-python) and a self-standing rust implementation of finite-state transducers mostly compatible with [HFST](https://hfst.github.io/). These two functions are liable to being split into multiple crates / packages in the future.
Able to load and execute [Voikko](https://voikko.puimula.org/) and [Omorfi](https://github.com/flammie/omorfi):
see [kfst](https://github.com/fergusq/fst-python) for transducers converted to a compatible format as well as Python bindings.
Supports the ATT format and its own KFST format.
To convert HFST (optimized lookup or otherwise) to ATT using HFST's tools, do:
```bash
hfst-fst2txt transducer.hfst -o transducer.att
```
# Using from Python
If you have kfst>=4.1 installed, simply do
```bash
pip install kfst-rs
```
to install kfst-rs. It should get automatically picked up by kfst and by extension pyvoikko and pyomorfi.
To check which implementation of kfst got loaded, look at the `BACKEND` property of kfst.
# Using from rust
Given the Voikko transducer in KFST or ATT format, one could create a simple analyzer like this:
```rust
use kfst_rs::{FSTState, FST};
use std::io::{self, Write};
// Read in transducer
let pathtovoikko = ...
let fst = FST::from_kfst_file(pathtovoikko, true).unwrap();
// Alternatively, for ATT use FST::from_att_file
// Read in word to analyze
let mut buffer = String::new();
let stdin = io::stdin();
stdin.read_line(&mut buffer).unwrap();
buffer = buffer.trim().to_string();
// Do analysis proper
match fst.lookup(&buffer, FSTState::default(), true) {
Ok(result) => {
for (i, analysis) in result.into_iter().enumerate() {
println!("Analysis {}: {} ({})", i+1, analysis.0, analysis.1)
}
},
Err(err) => println!("No analysis: {:?}", err),
}
```
Given the input "lentokoneessa", this gives the following analysis:
```text
Analysis 1: [Lt][Xp]lentää[X]len[Ln][Xj]to[X]to[Sn][Ny][Bh][Bc][Ln][Xp]kone[X]konee[Sine][Ny]ssa (0)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "kfst-rs",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "finnish, nlp, morphology, rust",
"author": "Th\u00e9o Salmenkivi-Friberg <theo.friberg@helsinki.fi>, Iikka Hauhio <iikka.hauhio@helsinki.fi>",
"author_email": "Th\u00e9o Salmenkivi-Friberg <theo.friberg@helsinki.fi>, Iikka Hauhio <iikka.hauhio@helsinki.fi>",
"download_url": null,
"platform": null,
"description": "# kfst-rs\n\nkfst-rs is both the optional acceleration back end of [kfst](https://github.com/fergusq/fst-python) and a self-standing rust implementation of finite-state transducers mostly compatible with [HFST](https://hfst.github.io/). These two functions are liable to being split into multiple crates / packages in the future.\n\nAble to load and execute [Voikko](https://voikko.puimula.org/) and [Omorfi](https://github.com/flammie/omorfi):\nsee [kfst](https://github.com/fergusq/fst-python) for transducers converted to a compatible format as well as Python bindings.\n\nSupports the ATT format and its own KFST format.\nTo convert HFST (optimized lookup or otherwise) to ATT using HFST's tools, do:\n```bash\nhfst-fst2txt transducer.hfst -o transducer.att\n```\n\n# Using from Python\n\nIf you have kfst>=4.1 installed, simply do\n\n```bash\npip install kfst-rs\n```\n\nto install kfst-rs. It should get automatically picked up by kfst and by extension pyvoikko and pyomorfi.\n\nTo check which implementation of kfst got loaded, look at the `BACKEND` property of kfst.\n\n# Using from rust\n\nGiven the Voikko transducer in KFST or ATT format, one could create a simple analyzer like this:\n```rust\nuse kfst_rs::{FSTState, FST};\nuse std::io::{self, Write};\n// Read in transducer\nlet pathtovoikko = ...\nlet fst = FST::from_kfst_file(pathtovoikko, true).unwrap();\n// Alternatively, for ATT use FST::from_att_file\n// Read in word to analyze\nlet mut buffer = String::new();\nlet stdin = io::stdin();\nstdin.read_line(&mut buffer).unwrap();\nbuffer = buffer.trim().to_string();\n// Do analysis proper\nmatch fst.lookup(&buffer, FSTState::default(), true) {\n Ok(result) => {\n for (i, analysis) in result.into_iter().enumerate() {\n println!(\"Analysis {}: {} ({})\", i+1, analysis.0, analysis.1)\n }\n },\n Err(err) => println!(\"No analysis: {:?}\", err),\n}\n```\nGiven the input \"lentokoneessa\", this gives the following analysis:\n```text\nAnalysis 1: [Lt][Xp]lent\u00e4\u00e4[X]len[Ln][Xj]to[X]to[Sn][Ny][Bh][Bc][Ln][Xp]kone[X]konee[Sine][Ny]ssa (0)\n```\n",
"bugtrack_url": null,
"license": "LGPL-3.0-or-later",
"summary": "The accelerated companion library to kfst",
"version": "0.2.4",
"project_urls": {
"Bug Tracker": "https://github.com/fergusq/fst-python/issues",
"Homepage": "https://github.com/fergusq/fst-python",
"Repository": "https://github.com/fergusq/fst-python"
},
"split_keywords": [
"finnish",
" nlp",
" morphology",
" rust"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "70a86699fe1cb5fdc2298d619b04e2145840f4349635eeace053a6ac69204865",
"md5": "6ceb329f176480c010f124009aea678b",
"sha256": "e003f735b1de4be6e446b7c5968863aeb34191743af36c490b14f55a37078dad"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-cp311-abi3-macosx_10_12_x86_64.whl",
"has_sig": false,
"md5_digest": "6ceb329f176480c010f124009aea678b",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.11",
"size": 950215,
"upload_time": "2025-07-23T13:36:46",
"upload_time_iso_8601": "2025-07-23T13:36:46.876510Z",
"url": "https://files.pythonhosted.org/packages/70/a8/6699fe1cb5fdc2298d619b04e2145840f4349635eeace053a6ac69204865/kfst_rs-0.2.4-cp311-abi3-macosx_10_12_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "3860e192ec45b393e1387d08fed2752518af6935f01ad749def1a31e2749f994",
"md5": "2b2118154fb8207dcaf4ead2ef733a15",
"sha256": "c03715059a91438028a0e0cc2b1c4aaf761e20049a735dc8064294bb78aa20f0"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-cp311-abi3-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "2b2118154fb8207dcaf4ead2ef733a15",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.11",
"size": 931952,
"upload_time": "2025-07-23T13:36:50",
"upload_time_iso_8601": "2025-07-23T13:36:50.490932Z",
"url": "https://files.pythonhosted.org/packages/38/60/e192ec45b393e1387d08fed2752518af6935f01ad749def1a31e2749f994/kfst_rs-0.2.4-cp311-abi3-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "01a6b48cd10b54039426534ffed50e7369d81ca46b32964f00586d463dad11bb",
"md5": "a5625dfce8990076070dd4ed50855958",
"sha256": "233f00877651d29dd6ea13761f471d6018c3b31e25d94462a9886d007b60eb55"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"has_sig": false,
"md5_digest": "a5625dfce8990076070dd4ed50855958",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.11",
"size": 464562,
"upload_time": "2025-07-23T13:36:53",
"upload_time_iso_8601": "2025-07-23T13:36:53.869263Z",
"url": "https://files.pythonhosted.org/packages/01/a6/b48cd10b54039426534ffed50e7369d81ca46b32964f00586d463dad11bb/kfst_rs-0.2.4-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4a1ca73a3cabcf8b0562f4ecf2bbbae0de01164515e96c761b8a0e071d91a858",
"md5": "c1a0027297cd19428f7f6bcb12500fa4",
"sha256": "0dbc72a0be3b75553ca6b5d7b0e38f14b7a6356c9866432d386b20d210187abc"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-cp311-abi3-manylinux_2_17_i686.manylinux2014_i686.whl",
"has_sig": false,
"md5_digest": "c1a0027297cd19428f7f6bcb12500fa4",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.11",
"size": 536432,
"upload_time": "2025-07-23T13:36:56",
"upload_time_iso_8601": "2025-07-23T13:36:56.740071Z",
"url": "https://files.pythonhosted.org/packages/4a/1c/a73a3cabcf8b0562f4ecf2bbbae0de01164515e96c761b8a0e071d91a858/kfst_rs-0.2.4-cp311-abi3-manylinux_2_17_i686.manylinux2014_i686.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5256b70d2fd9c527d4877925841eae6aa723574d4a01108aee5c91c9a6d39b67",
"md5": "d7d596184170954e88ddf1b1f06016ab",
"sha256": "cef86e0e2d39f34767ea8316cbd3e4d5626d30a15263822b6df40d84ce626149"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "d7d596184170954e88ddf1b1f06016ab",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.11",
"size": 490557,
"upload_time": "2025-07-23T13:36:58",
"upload_time_iso_8601": "2025-07-23T13:36:58.777878Z",
"url": "https://files.pythonhosted.org/packages/52/56/b70d2fd9c527d4877925841eae6aa723574d4a01108aee5c91c9a6d39b67/kfst_rs-0.2.4-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a4de096eec890aa7dc59b3cb9204fba13df6eff6170ecefda7b87c1cbdb3f4c6",
"md5": "5bc8384f1709726a58d2ae9c729919b5",
"sha256": "3daeded7f82d8df82f35f3ba2354e5d04ccb9cf1ded206fb1622ec4991d17bcf"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-cp311-abi3-musllinux_1_2_aarch64.whl",
"has_sig": false,
"md5_digest": "5bc8384f1709726a58d2ae9c729919b5",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.11",
"size": 462002,
"upload_time": "2025-07-23T13:37:00",
"upload_time_iso_8601": "2025-07-23T13:37:00.739168Z",
"url": "https://files.pythonhosted.org/packages/a4/de/096eec890aa7dc59b3cb9204fba13df6eff6170ecefda7b87c1cbdb3f4c6/kfst_rs-0.2.4-cp311-abi3-musllinux_1_2_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "79cbdd84dcd094c6052a795250897785f10b1d0a5342fbf0d016bb207391ddcd",
"md5": "85a2f5dd3c4d6b3e7e91843870ee569d",
"sha256": "9240085075bf91596474d5930db35dae9736cdf58bff09743ff3b9d1c0edb0d9"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-cp311-abi3-musllinux_1_2_i686.whl",
"has_sig": false,
"md5_digest": "85a2f5dd3c4d6b3e7e91843870ee569d",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.11",
"size": 518360,
"upload_time": "2025-07-23T13:37:03",
"upload_time_iso_8601": "2025-07-23T13:37:03.310168Z",
"url": "https://files.pythonhosted.org/packages/79/cb/dd84dcd094c6052a795250897785f10b1d0a5342fbf0d016bb207391ddcd/kfst_rs-0.2.4-cp311-abi3-musllinux_1_2_i686.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ffee57d9f12fc0623e0eab6911ee59bd47e987147b28df1786bac556c4390354",
"md5": "72757af57a5b344e4480dfebd40183ae",
"sha256": "be3108f5a8d7b27bc58935a5dce221ce85b494873e432c6dbd47f852cd787cc1"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-cp311-abi3-musllinux_1_2_x86_64.whl",
"has_sig": false,
"md5_digest": "72757af57a5b344e4480dfebd40183ae",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.11",
"size": 489184,
"upload_time": "2025-07-23T13:37:05",
"upload_time_iso_8601": "2025-07-23T13:37:05.235602Z",
"url": "https://files.pythonhosted.org/packages/ff/ee/57d9f12fc0623e0eab6911ee59bd47e987147b28df1786bac556c4390354/kfst_rs-0.2.4-cp311-abi3-musllinux_1_2_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d6fa0ec0b2b681efd8fabb67b4f1e871a8f0a154c5f3ea225b02896cf0f6b43e",
"md5": "667b3e2f25fca7804d236144439e15df",
"sha256": "fbf54bb1e862d4c0ed7554d2525cab6983127c80709feec76faed28f1c5394e0"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-cp311-abi3-win_amd64.whl",
"has_sig": false,
"md5_digest": "667b3e2f25fca7804d236144439e15df",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.11",
"size": 821966,
"upload_time": "2025-07-23T13:37:07",
"upload_time_iso_8601": "2025-07-23T13:37:07.471137Z",
"url": "https://files.pythonhosted.org/packages/d6/fa/0ec0b2b681efd8fabb67b4f1e871a8f0a154c5f3ea225b02896cf0f6b43e/kfst_rs-0.2.4-cp311-abi3-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7b7dc1866293b931cac557c063ef3c44d85a6b702fb97b7fa293f96e0b6d87ab",
"md5": "1506b42b38905d704492d2a25e08f283",
"sha256": "cd68377bf8d44088b747bea9c4f7775bc8c1a916034492cd1f46f5d271692b3a"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-cp311-abi3-win_arm64.whl",
"has_sig": false,
"md5_digest": "1506b42b38905d704492d2a25e08f283",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.11",
"size": 733135,
"upload_time": "2025-07-23T13:37:09",
"upload_time_iso_8601": "2025-07-23T13:37:09.208124Z",
"url": "https://files.pythonhosted.org/packages/7b/7d/c1866293b931cac557c063ef3c44d85a6b702fb97b7fa293f96e0b6d87ab/kfst_rs-0.2.4-cp311-abi3-win_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "2a8d8e9dd953c8cec6e01bf8fa0d2b8c5b39112064e2da06e1c7fe93334c6aed",
"md5": "fb5b014b2231518a25053c29ce50cf96",
"sha256": "a7c9410b74a9ef9d012285a3c053e8f28167316d0fefb02b52015bacadd1b1ab"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-cp313-cp313t-win_amd64.whl",
"has_sig": false,
"md5_digest": "fb5b014b2231518a25053c29ce50cf96",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.11",
"size": 825789,
"upload_time": "2025-07-23T13:37:11",
"upload_time_iso_8601": "2025-07-23T13:37:11.363980Z",
"url": "https://files.pythonhosted.org/packages/2a/8d/8e9dd953c8cec6e01bf8fa0d2b8c5b39112064e2da06e1c7fe93334c6aed/kfst_rs-0.2.4-cp313-cp313t-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "c97b8af2e54ec495c598cfb0be1751e305a5debf6c84737af2051ec24401e93c",
"md5": "e05d611079c5bf8b4c17a0b4e4aec297",
"sha256": "8358a5a09767f13d98ca963b5dade16ee0d73e35d4d9fdd8ea6f594dbd9f3217"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-cp313-cp313t-win_arm64.whl",
"has_sig": false,
"md5_digest": "e05d611079c5bf8b4c17a0b4e4aec297",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.11",
"size": 736005,
"upload_time": "2025-07-23T13:37:13",
"upload_time_iso_8601": "2025-07-23T13:37:13.059060Z",
"url": "https://files.pythonhosted.org/packages/c9/7b/8af2e54ec495c598cfb0be1751e305a5debf6c84737af2051ec24401e93c/kfst_rs-0.2.4-cp313-cp313t-win_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "453e5355ed565a3c6c2e3abc2a8b688f47377356868e6233cddba23d38f4554c",
"md5": "c7bb659dacb43c24af7a7ce776c6848f",
"sha256": "14f73722ee96bd4c4a55d3efe37768e195725427b12e5982a8973190d279c0fe"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-pp310-pypy310_pp73-win_amd64.whl",
"has_sig": false,
"md5_digest": "c7bb659dacb43c24af7a7ce776c6848f",
"packagetype": "bdist_wheel",
"python_version": "pp310",
"requires_python": ">=3.11",
"size": 819894,
"upload_time": "2025-07-23T13:37:16",
"upload_time_iso_8601": "2025-07-23T13:37:16.900203Z",
"url": "https://files.pythonhosted.org/packages/45/3e/5355ed565a3c6c2e3abc2a8b688f47377356868e6233cddba23d38f4554c/kfst_rs-0.2.4-pp310-pypy310_pp73-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "b8af2e230aefa15733fcb40388e7becb0449a7d539255e76262f1dff6ac86b5d",
"md5": "c3f6fafb1a6ca13d704dd177a18e68fb",
"sha256": "430e8b175faf0b6e4ef3703688f062c90b671023e49c07d8c0e9c74fea33db39"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-pp311-pypy311_pp73-win_amd64.whl",
"has_sig": false,
"md5_digest": "c3f6fafb1a6ca13d704dd177a18e68fb",
"packagetype": "bdist_wheel",
"python_version": "pp311",
"requires_python": ">=3.11",
"size": 820920,
"upload_time": "2025-07-23T13:37:18",
"upload_time_iso_8601": "2025-07-23T13:37:18.780722Z",
"url": "https://files.pythonhosted.org/packages/b8/af/2e230aefa15733fcb40388e7becb0449a7d539255e76262f1dff6ac86b5d/kfst_rs-0.2.4-pp311-pypy311_pp73-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "cafd868cac0ba5eea7e9281872c3366c49f5ed6391025446414f45e0eea93c34",
"md5": "3cf4f324f11b3faab6396542214b4dbf",
"sha256": "acb56f62cd19e3569cf698f8c6c761013316c15db4326b21fdd3fb4f7efc5466"
},
"downloads": -1,
"filename": "kfst_rs-0.2.4-pp39-pypy39_pp73-win_amd64.whl",
"has_sig": false,
"md5_digest": "3cf4f324f11b3faab6396542214b4dbf",
"packagetype": "bdist_wheel",
"python_version": "pp39",
"requires_python": ">=3.11",
"size": 820477,
"upload_time": "2025-07-23T13:37:14",
"upload_time_iso_8601": "2025-07-23T13:37:14.824726Z",
"url": "https://files.pythonhosted.org/packages/ca/fd/868cac0ba5eea7e9281872c3366c49f5ed6391025446414f45e0eea93c34/kfst_rs-0.2.4-pp39-pypy39_pp73-win_amd64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-23 13:36:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fergusq",
"github_project": "fst-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "kfst-rs"
}