initial commit
This commit is contained in:
commit
3da24a973e
|
@ -0,0 +1 @@
|
|||
build/
|
|
@ -0,0 +1,27 @@
|
|||
# Copyright (c) 2023 Emma Tebibyte <emma@tebibyte.media>
|
||||
# SPDX-License-Identifier: FSFAP
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice and this
|
||||
# notice are preserved. This file is offered as-is, without any warranty.
|
||||
|
||||
.POSIX:
|
||||
|
||||
PREFIX=/usr/local
|
||||
CFLAGS=-O3 -s -Wl,-z,noseparate-code,-z,nosectionheader -flto
|
||||
LD_LIBRARY_PATH=/usr/local/lib
|
||||
|
||||
build: build_dir tokiponize
|
||||
|
||||
clean: build_dir
|
||||
rm -rf build/
|
||||
|
||||
tokiponize: tokiponize.c build_dir
|
||||
cc $(CFLAGS) -L$(LD_LIBRARY_PATH) -lyac -o build/tokiponize tokiponize.c
|
||||
|
||||
build_dir:
|
||||
mkdir -p build
|
||||
|
||||
install: build
|
||||
mkdir -p $(PREFIX)/bin
|
||||
cp -f build/tokiponize $(PREFIX)/bin/
|
|
@ -0,0 +1,23 @@
|
|||
.TH TOKIPONIZE 1
|
||||
.SH NAME
|
||||
.B tokiponize
|
||||
ante e nimi Lasina tawa nimi sitelen pona.
|
||||
.SH SYNOPSIS
|
||||
.B tokiponize
|
||||
.SH DESCRIPTION
|
||||
ilo tokiponize li ante e nimi Lasina tawa nimi sitelen pona. ona li sitelen e
|
||||
ni.
|
||||
.SH AUTHOR
|
||||
sitelen tan jan Ema Tepipatu.
|
||||
.SH REPORTING BUGS
|
||||
lon lipu pakala la o toki e pakala tawa mi. ona lon
|
||||
<https://git.tebibyte.media/emma/tokiponize>.
|
||||
.SH COPYRIGHT
|
||||
Copyright \(co 2023 Emma Tebibyte.
|
||||
License AGPLv3+: GNU AGPL version 3 or later
|
||||
<https://gnu.org/licenses/agpl.html>.
|
||||
.br
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law.
|
||||
.SH SEE ALSO
|
||||
.B lolcat(1)
|
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Emma Tebibyte <emma@tebibyte.media>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sysexits.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <uthash.h>
|
||||
#include <yac.h>
|
||||
|
||||
const char *TOKI_PONA_KEY[] = {
|
||||
"a", "",
|
||||
"akesi", "",
|
||||
"ala", "",
|
||||
"alasa", "",
|
||||
"ale", "",
|
||||
"anpa", "",
|
||||
"ante", "",
|
||||
"anu", "",
|
||||
"awen", "",
|
||||
"e", "",
|
||||
"en", "",
|
||||
"esun", "",
|
||||
"ijo", "",
|
||||
"ike", "",
|
||||
"ilo", "",
|
||||
"insa", "",
|
||||
"jaki", "",
|
||||
"jan", "",
|
||||
"jelo", "",
|
||||
"jo", "",
|
||||
"kala", "",
|
||||
"kalama", "",
|
||||
"kama", "",
|
||||
"kasi", "",
|
||||
"ken", "",
|
||||
"kepeken", "",
|
||||
"kili", "",
|
||||
"kiwen", "",
|
||||
"ko", "",
|
||||
"kon", "",
|
||||
"kule", "",
|
||||
"kulupu", "",
|
||||
"kute", "",
|
||||
"la", "",
|
||||
"lape", "",
|
||||
"laso", "",
|
||||
"lawa", "",
|
||||
"len", "",
|
||||
"lete", "",
|
||||
"li", "",
|
||||
"lili", "",
|
||||
"linja", "",
|
||||
"lipu", "",
|
||||
"loje", "",
|
||||
"lon", "",
|
||||
"luka", "",
|
||||
"lukin", "",
|
||||
"lupa", "",
|
||||
"ma", "",
|
||||
"mama", "",
|
||||
"mani", "",
|
||||
"meli", "",
|
||||
"mi", "",
|
||||
"mije", "",
|
||||
"moku", "",
|
||||
"moli", "",
|
||||
"monsi", "",
|
||||
"mu", "",
|
||||
"mun", "",
|
||||
"musi", "",
|
||||
"mute", "",
|
||||
"nanpa", "",
|
||||
"nasa", "",
|
||||
"nasin", "",
|
||||
"nena", "",
|
||||
"ni", "",
|
||||
"nimi", "",
|
||||
"noka", "",
|
||||
"o", "",
|
||||
"olin", "",
|
||||
"ona", "",
|
||||
"open", "",
|
||||
"pakala", "",
|
||||
"pali", "",
|
||||
"palisa", "",
|
||||
"pan", "",
|
||||
"pana", "",
|
||||
"pi", "",
|
||||
"pilin", "",
|
||||
"pimeja", "",
|
||||
"pini", "",
|
||||
"pipi", "",
|
||||
"poka", "",
|
||||
"poki", "",
|
||||
"pona", "",
|
||||
"pu", "",
|
||||
"sama", "",
|
||||
"seli", "",
|
||||
"selo", "",
|
||||
"seme", "",
|
||||
"sewi", "",
|
||||
"sijelo", "",
|
||||
"sike", "",
|
||||
"sin", "",
|
||||
"sina", "",
|
||||
"sinpin", "",
|
||||
"sitelen", "",
|
||||
"sona", "",
|
||||
"soweli", "",
|
||||
"suli", "",
|
||||
"suno", "",
|
||||
"supa", "",
|
||||
"suwi", "",
|
||||
"tan", "",
|
||||
"taso", "",
|
||||
"tawa", "",
|
||||
"telo", "",
|
||||
"tenpo", "",
|
||||
"toki", "",
|
||||
"tomo", "",
|
||||
"tu", "",
|
||||
"unpa", "",
|
||||
"uta", "",
|
||||
"utala", "",
|
||||
"walo", "",
|
||||
"wan", "",
|
||||
"waso", "",
|
||||
"wawa", "",
|
||||
"weka", "",
|
||||
"wile", "",
|
||||
"namako", "",
|
||||
"kin", "",
|
||||
"oko", "",
|
||||
"kipisi", "",
|
||||
"leko", "",
|
||||
"monsuta", "",
|
||||
"tonsi", "",
|
||||
"jasima", "",
|
||||
"kijetesantakalu", "",
|
||||
"soko", "",
|
||||
"meso", "",
|
||||
"epiku", "",
|
||||
"kokosila", "",
|
||||
"lanpan", "",
|
||||
"n", "",
|
||||
"misikeke", "",
|
||||
"ku", "",
|
||||
"pake", "",
|
||||
"apeja", "",
|
||||
"majuna", "",
|
||||
"powe", ""
|
||||
};
|
||||
|
||||
struct nimi {
|
||||
const char *word;
|
||||
const char *glyph;
|
||||
UT_hash_handle hh;
|
||||
};
|
||||
|
||||
struct nimi *nimi_mute = NULL;
|
||||
|
||||
const char *ante(char *search_word, struct nimi *n) {
|
||||
const char *pana;
|
||||
|
||||
struct nimi *result = NULL;
|
||||
|
||||
HASH_FIND_STR(n, search_word, result);
|
||||
|
||||
if (result) {
|
||||
pana = result->glyph;
|
||||
} else { pana = search_word; }
|
||||
return pana;
|
||||
}
|
||||
|
||||
void lukin(FILE *file, struct nimi *n) {
|
||||
int byte;
|
||||
char *lasina[16];
|
||||
|
||||
for (int i = 0; (byte = fgetc(file)) != EOF; i++) {
|
||||
switch (byte) {
|
||||
case ' ':
|
||||
lasina[i] = '\0';
|
||||
printf("%s ", ante(lasina, n));
|
||||
i = -1;
|
||||
break;
|
||||
case '\n':
|
||||
lasina[i] = '\0';
|
||||
printf("%s\n", ante(lasina, n));
|
||||
i = -1;
|
||||
break;
|
||||
default:
|
||||
lasina[i] = byte;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
for (int i = 0; i < sizeof(TOKI_PONA_KEY) / sizeof(char *); i += 2) {
|
||||
const char *word = TOKI_PONA_KEY[i];
|
||||
const char *glyph = TOKI_PONA_KEY[i + 1];
|
||||
|
||||
struct nimi *n = malloc(sizeof(struct nimi));
|
||||
|
||||
if (n == NULL) { exit(1); }
|
||||
|
||||
n->word = word;
|
||||
n->glyph = glyph;
|
||||
|
||||
HASH_ADD_KEYPTR(hh, nimi_mute, n->word, strlen(n->word), n);
|
||||
}
|
||||
|
||||
if (argc = 1) {
|
||||
lukin(stdin, nimi_mute);
|
||||
}
|
||||
|
||||
FILE *file;
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
file = rpath(argv[0], argv[i]);
|
||||
if (file != NULL) {
|
||||
lukin(file, nimi_mute);
|
||||
if (file != stdin) { fclose(file); }
|
||||
} else { continue; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue