Skip to content

Commit

Permalink
add type hint and docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-bearabbit committed Nov 17, 2024
1 parent fd8c7d1 commit 2327196
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[package]
name = "tossicat-python"
version = "0.1.2"
version = "0.1.3"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
name = "tossicat"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.22.6", features = ["extension-module"] }
tossicat = "0.6.1"

[package.metadata.maturin]
include = ["tossicat.pyi"]
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;

#[pyfunction]
#[pyo3(text_signature = "(word, tossi)")]
/// The transform function takes two strings (word, tossi) as input and returns a tuple containing the word
/// and tossi transformed according to Korean grammar rules.
pub fn transform(word: &str, tossi: &str) -> PyResult<(String, String)> {
match ::tossicat::transform(word, tossi) {
Ok(result) => Ok(result),
Expand All @@ -12,6 +15,8 @@ pub fn transform(word: &str, tossi: &str) -> PyResult<(String, String)> {
}

#[pyfunction]
#[pyo3(text_signature = "(word, tossi)")]
/// The postfix function takes two strings (word, tossi) as input and returns the appropriate tossi.
pub fn postfix(word: &str, tossi: &str) -> PyResult<String> {
match ::tossicat::postfix(word, tossi) {
Ok(result) => Ok(result),
Expand All @@ -22,6 +27,9 @@ pub fn postfix(word: &str, tossi: &str) -> PyResult<String> {
}

#[pyfunction]
#[pyo3(text_signature = "(sentence)")]
/// The modify_sentence function takes a sentence containing {word, tossi} templates as input
/// and returns a modified sentence with the templates properly adjusted.
pub fn modify_sentence(sentence: &str) -> PyResult<String> {
match ::tossicat::modify_sentence(sentence) {
Ok(result) => Ok(result),
Expand Down
9 changes: 9 additions & 0 deletions tossicat.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# tossicat.pyi

from typing import Tuple

def transform(word: str, tossi: str) -> Tuple[str, str]: ...

def postfix(word: str, tossi: str) -> str: ...

def modify_sentence(sentence: str) -> str: ...

0 comments on commit 2327196

Please sign in to comment.