Updated source code from upstream SVN
[svmtool++.git] / include / common.h
blobe8ca31fb6f20e534d2fa402099d90984b97e7991
1 /*
2 * Copyright (C) 2004 Jesus Gimenez, Lluis Marquez and Senen Moya
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef COMMON_H
21 #include <time.h>
22 #include <sys/times.h>
23 #include "list.h"
24 #include <string>
25 #include <algorithm>
26 #include <vector>
28 using namespace std;
30 #define CLOCKS_PER_SECOND sysconf(_SC_CLK_TCK)
31 #define TRUE 1
32 #define FALSE 0
33 #define KNOWN 11
34 #define UNKNOWN 22
35 #define LEFT_TO_RIGHT 1
36 #define RIGHT_TO_LEFT 2
37 #define LR_AND_RL 3
39 #define TAM_MARK 10
40 #define TAM_POS 10
41 #define TAM_WORD 100
42 #define TAM_LINE 200
44 #define RM_MODEL_FILES 1001
45 #define RM_TEMP_FILES 1002
47 struct nodo_feature_list
49 nodo_feature_list() :
50 mark(),
51 l()
54 /* the type of the feature. see marks.h for different types */
55 std::string mark;
56 /* words concerned, eg. (-2, -1, 0) */
57 simpleList<int*> l;
61 FILE *openFile(const std::string& name, const char mode[]);
62 void generateFileName(const std::string& name, const std::string& added, int numModel, int direction, int what, const std::string& type, string& out);
64 void showProcessDone(int num,int freq, int isEnd, const std::string& what);
65 void showProcess(int num, int isEnd);
66 //void showTime(char *what, clock_t start,clock_t end, struct tms tbuff1,struct tms tbuff2);
67 void showTime(const std::string& what, double real, double utime,double stime);
69 int goToWord(FILE *f, int offset);
71 int readString(FILE* f, string& out);
72 int readTo(FILE* f, char endChar, char endLine, string& out);
73 //void saltarLinea(FILE *f);
75 void qsort(int a[], int lo, int hi);
77 int ordenarStringPorParejas(const char* szIn, char* szOut, int depth, char* szInicial);
79 void destroyFeatureList(simpleList<nodo_feature_list*> *);
80 void createFeatureList(const std::string& name,simpleList<nodo_feature_list*> *featureList);
81 void removeFiles(const std::string& path, int type,int numModel, int direction, int verbose);
82 void Tokenize(const string& str, vector<string>& tokens, const string& delimiters);
85 #define COMMON_H
86 #endif