forked from rhdunn/rsynth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
guess.c
109 lines (99 loc) · 2.54 KB
/
guess.c
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
/*
Copyright (c) 1994,2001-2002 Nick Ing-Simmons. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "darray.h"
#include "charset.h"
#include "text.h"
#include "phones.h"
#include "lang.h"
#include "english.h"
#include "say.h"
lang_t *lang = &English;
unsigned
xlate_string(char *string, darray_ptr phone)
{
abort(); /* just a stub */
}
int main(int argc,char *argv[])
{
darray_t phone;
darray_init(&phone, sizeof(char), 128);
init_locale();
if (argc > 1)
{
rule_debug = 1;
while (--argc)
{
char *s = *++argv;
NRL(s,strlen(s),&phone);
darray_append(&phone,0);
printf("%s [%s]\n",s,(char *) darray_find(&phone,0));
phone.items = 0;
}
}
else
{
char buf[1024];
unsigned char *s;
unsigned total = 0;
unsigned right = 0;
while ((s = (unsigned char *) fgets(buf,sizeof(buf),stdin)))
{
while (*s && isspace(*s)) s++;
if (*s)
{
unsigned char *e = s;
unsigned char *p;
while (*e && !isspace(*e)) e++;
NRL(s,(e-s),&phone);
darray_append(&phone,0);
p = e;
while (*p && isspace(*p)) p++;
if (*p)
{
char *q = p;
total++;
while (*q && !isspace(*q)) q++;
*q++ = ' ';
*q = '\0';
if (strcmp(p,darray_find(&phone,0)) != 0)
{
printf("%.*s",(e-s),s);
printf(" expected /%s/, got /%s/\n",p,(char *) darray_find(&phone,0));
}
else
{
right++;
}
}
else
{
printf("%.*s",(e-s),s);
printf(" got /%s/\n",(char *) darray_find(&phone,0));
fflush(stdout);
}
phone.items = 0;
}
}
if (total)
{
fprintf(stderr,"%.3g%% correct\n",right*100.0/total);
}
}
return 0;
}