mirror of
https://github.com/tomasriveral/nixos.git
synced 2026-08-12 02:28:37 +02:00
dendritic: rewrote entire config
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
{ ... }:
|
||||
{
|
||||
flake.packages.custom-syllabes = { pkgs, ... }:
|
||||
# counts how many syllabes in a string.
|
||||
# not perfect. Does not handle silents e in french
|
||||
# but that's what I use for writing poetry
|
||||
pkgs.writers.writePython3Bin "custom-syllabes" {
|
||||
libraries = with pkgs; [
|
||||
python3Packages.pyphen
|
||||
];
|
||||
} ''
|
||||
import sys
|
||||
import pyphen
|
||||
|
||||
dic = pyphen.Pyphen(lang="fr")
|
||||
|
||||
text = sys.stdin.read().strip()
|
||||
|
||||
chunks = []
|
||||
total = 0
|
||||
|
||||
for w in text.split():
|
||||
hyphenated = dic.inserted(w)
|
||||
parts = hyphenated.split("-")
|
||||
chunks.append("/".join(parts))
|
||||
total += len(parts)
|
||||
|
||||
print(f"{total} ({'/'.join(chunks)})")
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user