2 * Copyright (C) 2005 Universitat d'Alacant / Universidad de Alicante
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 #include <apertium/TaggerUtils.H>
23 void fatal_error (string s) {
24 cerr<<"Error: "<<s<<"\n";
28 void file_name_error (string s) {
29 fatal_error(s+" in not a valid file");
38 void clear_array_double(double a[], int l) {
39 for(int i=0; i<l; i++)
43 void clear_array_vector(vector<TTag> v[], int l) {
44 for(int i=0; i<l; i++)
48 int ntokens_multiword(string s) {
49 char *news = strdup((char*) s.c_str());
53 if (strtok(news,delim))
55 while (strtok(NULL, delim))
61 int nguiones_fs(string s) {
62 char *news = strdup((char*) s.c_str());
66 if (strtok(news,delim))
68 while (strtok(NULL, delim))
73 string trim(string s) {
77 for (unsigned int i=0; i<(s.length()-1); i++) {
78 if ((s.at(i)==' ')&&(s.at(i+1)==' ')) {
84 if ((s.length()>0)&&(s.at(s.length()-1)==' '))
85 s.erase(s.length()-1,1);
86 if ((s.length()>0)&&(s.at(0)==' '))