summaryrefslogtreecommitdiff
path: root/uryuomoco2english.c
blob: 0cf14cf0ef3684426c11cad5d97fa2bdaad9ed8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include <stdio.h>
#include <ctype.h>

// uryuomoco to english
//          abcdefghijklmnopqrstuvwxyz
char trl[]="uvsjohtfydprnmekwlcgabqzix";

/*
 * a->u
 * ais->ss
 * b->v
 * c->s
 * ch->th
 * d->j
 * e->o
 * f->h
 * g->t
 * gis->ts
 * h->f
 * i->y
 * ja->d
 * k->p
 * l->r
 * m->n
 * n->m
 * o->e
 * ot ->ing 
 * p->k
 * qu->w
 * quo->wh
 * r->l
 * ra->ll
 * s->c	
 * se->ch
 * t->g 
 * tul->gr
 * u->a
 * us->sh
 * v->b
 * w->qu
 * x->z
 * y->i
 * z->x
 */

int tr(int c){
	int retval;
	static int prev=0;
	static int prevprev=0;
	if(islower(c)){
		switch(c){
			case 'a':
				if(prev=='j') break; // ja->d
				else if(prev=='r') retval=putchar('l'); // ra->ll
				else{ // ais->ss, a->u, 
					c=getchar();
					if(c=='i'){ // ai
						c=getchar();
						if(c=='s'){ // ais
							putchar('s');
							retval=putchar('s');
							break;
						}else{ // ai?
							putchar('u');
							retval=putchar('y');
						}
					}else{ // a?
						retval=putchar('u');
					}
					return tr(c);
				}
				break;
			case 'c':
				c=getchar();
				if(c=='h'){ // ch->th
					putchar('t');
					retval=putchar('h');
				}else{ // c->s
					putchar('s');
					return tr(c);
				}
				break;
			case 'e': retval=putchar(prev=='s'?'h':'o'); break; // se->ch, s->c
			case 'h': retval=(prevprev=='m'&&prev=='e'?'f':putchar('f')); break; // meh -> no , h->f
			case 'i':
				  if(prev=='g'){ // gi
					  c=getchar();
					  if(c=='s'){ // gis -> ts
						  retval=putchar('s');
					  }else{ // gi?
						  putchar('y'); // i->y
						  return tr(c);
					  }
				  }else retval=putchar('y'); // i->y
				  break;
			case 'o':
				  if(prevprev=='q'&&prev=='u') retval=putchar('h'); // quo->wh
				  else{
					  c=getchar();
					  if(c=='t'){ // ot
						  c=getchar();
						  if(!islower(c)){ // -ot -> -ing
							  putchar('i');
							  putchar('n');
							  putchar('g');
							  retval=putchar(c);
						  }else{ // ot?
							  putchar('e');
							  putchar('g');
							  prev='t';
							  return(tr(c));
						  }
					  }else{
						  putchar('e'); // o->e
						  prev='o';
						  return(tr(c));
					  }
				  }
				  break;
			case 'u': if(prev=='q') break; // qu->w
				  else if(prev=='y') break; // yu->i
				  c=getchar();
				  if(prev=='t'){ // tu
					if(c=='l'){ // tul->gr
						retval=putchar('r');
					}else{ // tu?
						putchar('a');
						prev='u';
						return tr(c);
					}
				  }else{ // u
					if(!islower(prev)&&c=='s'){ //  us-> sh
						putchar('s');
						retval=putchar('h');
					}else{ // u->a
						putchar('a');
						prev='u';
						return tr(c);		  
					}
				  }
				  break;
			case 'w': putchar('q'); retval=putchar('u'); break; // w -> qu
			default: retval=putchar(trl[c-'a']); // single to single
		}
	}else retval=putchar(c);
	prevprev=prev;
	prev=c;
	return retval;
}

int main(int argc, char** argv){
	int c;
	do{
		c=getchar();
	}while(c!=EOF && tr(c)!=EOF);
	return 0;
}