pun-sort: package api

This commit is contained in:
2025-12-28 22:12:51 +01:00
parent 950805bc9d
commit 5f0b8d90a8
4 changed files with 40 additions and 8 deletions

23
flake.lock generated
View File

@@ -16,6 +16,22 @@
}
},
"nixpkgs": {
"locked": {
"lastModified": 1766870016,
"narHash": "sha256-fHmxAesa6XNqnIkcS6+nIHuEmgd/iZSP/VXxweiEuQw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5c2bc52fb9f8c264ed6c93bd20afa2ff5e763dce",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1665296151,
"narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=",
@@ -33,17 +49,14 @@
},
"root": {
"inputs": {
"nixpkgs": [
"rust-overlay",
"nixpkgs"
],
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1677119371,

View File

@@ -2,8 +2,8 @@
description = "All kinds of stuff";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
nixpkgs.follows = "rust-overlay/nixpkgs";
};
outputs =
@@ -52,6 +52,7 @@
};
onomap = pkgs.haskellPackages.callCabal2nix "onomap" ./onomastics-ng { };
hesychius = hesychius/hesychius.txt;
pun-sort-api = pkgs.callPackage ./pun-sort {};
alarm = pkgs.writers.writeDashBin "alarm" ''
set -efu
export PATH=${

19
pun-sort/default.nix Normal file
View File

@@ -0,0 +1,19 @@
{ writers, python3Packages }:
writers.writePython3Bin "pun_sort_api.py" {
flakeIgnore = [
"E203"
"E203"
"E226"
"E302"
"E305"
"E501"
"F841"
"W503"
];
libraries = [
python3Packages.fastapi
python3Packages.uvicorn
python3Packages.pydantic
python3Packages.pydantic-core
];
} ./sort_api.py

View File

@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""
FastAPI backend for phonetic word sorting
Sorts words by their phonetic similarity using espeak-ng IPA transcription
@@ -6,7 +5,7 @@ Sorts words by their phonetic similarity using espeak-ng IPA transcription
from fastapi import FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel, Field
from typing import List, Optional
from typing import List
import string
import subprocess
from functools import lru_cache