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.
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
26 struct samples_counter_t
36 int learnerNumAMBP
,learnerNumUNKP
;
37 hash_t
<infoDict
*>* learnerAMBP_H
;
38 hash_t
<infoDict
*>* learnerUNKP_H
;
40 simpleList
<nodo_feature_list
*> learnerFeatureList
;
41 simpleList
<infoDict
*>* learnerAMBP_L
;
42 simpleList
<infoDict
*>* learnerUNKP_L
;
43 FILE *fKnown
,*fUnknown
;
44 int learnerNumFeatures
;
45 char obtainAtrChar(FILE *channel
);
46 int obtainAtrInt(FILE *channel
,int *endAtr
);
47 // void learnerCreateFeatureList(char *name, simpleList *featureList);
48 simpleList
<infoDict
*>* learnerTransformHashInList(hash_t
<infoDict
*> *tptr
);
49 void learnerCreateDefaultFile(const std::string
& modelName
, const std::string
& str
);
50 void learnerCreatePOSFile(const std::string
& modelName
, int is_ambp
, hash_t
< infoDict
* >* h
);
51 void learnerCount(const std::string
& name
, int* nWords
, int* nSentences
);
52 int learnerExecSVMlight(const std::string
& svmdir
, const std::string
& options
, const std::string
& posFile
, const std::string
& outFile
);
53 int learnerLeftToRight(simpleList
< nodo_feature_list
* >* featureList
, simpleList
< nodo_feature_list
* >* featureListUnk
, dictionary
* dKnown
, dictionary
* dUnknown
, int numWrds
, int inicio
);
54 int learnerRightToLeft(simpleList
< nodo_feature_list
* >* featureList
, simpleList
< nodo_feature_list
* >* featureListUnk
, dictionary
* dKnown
, dictionary
* dUnknown
, int numWrds
, int inicio
);
55 void learnerGetFeatures(nodo
* elem
, std::stack
< std::string
, std::deque
< std::string
, std::allocator
< std::string
> > >& stk
, dictionary
* d
, simpleList
< nodo_feature_list
* >* featureList
, int direction
);
56 void learnerGenerateFeatures(nodo
* elem
, simpleList
< nodo_feature_list
* >* featureList
, dictionary
* d
, int direction
);
57 void learnerGenerateFeaturesUnk(nodo
* elem
, simpleList
< nodo_feature_list
* >* featureList
, dictionary
* d
, dictionary
* dUnk
, int direction
);
58 void learnerTrainModel(const std::string
& trainingFileName
, dictionary
* dKnown
, int numModel
, int direction
, int numSent
, int numWords
, int numChunks
);
59 weightRepository
* learnerBuiltWeightRepository(weightRepository
*wr
,mapping
*m
,const std::string
& pos
,const std::string
& fileName
);
60 hash_t
<weight_node_t
*>* learnerBuiltBias(hash_t
<weight_node_t
*>* h
, const std::string
& pos
, const std::string
& fileName
);
61 void learnerDestroyBias(hash_t
<weight_node_t
*> *h
);
62 int learnerIsPossiblePOS(const std::string
& wrd
, const std::string
& pos
, int Known_or_Unknown
);
63 simpleList
<infoDict
*>* learnerGetPotser(const std::string
& wrd
, int Known_or_Unknown
, dictionary
*d
);
64 // void learnerTraining(FILE *f,char *modelName, int numModel,int LR_or_RL,int K_or_U,dictionary *d,simpleList *lpos);
65 void learnerPrintMessage(int numModel
, int K_or_U
, int LR_or_RL
,int is_fex
);
66 int learnerNumChunks(const std::string
& trainingFileName
, float percentage
, int nSentences
);
67 bool learnerIsInsideList(simpleList
< infoDict
* >* l
, const std::string
& key
);
68 void learnerDoLearn(FILE *f
,int numModel
,int LR_or_RL
,int K_or_U
,dictionary
*d
,simpleList
<infoDict
*>* lPosToTrain
);
69 void learnerDressNakedSetTrain(dictionary
*d
,mapping
*m
,FILE *f
, const std::string
& pos
, int numModel
, int direction
, int K_or_U
,int *nPos
,int *nNeg
);
70 void learnerPushSample(const std::string
& wrd
,int numModel
,int direction
, int Known_or_Unknown
, const std::string
& pos
,const std::string
& samplePos
,const std::string
& features
,dictionary
*d
, int *nNeg
, int *nPos
);
71 void learnerPushSampleUnk(const std::string
& wrd
,int numModel
,int direction
, int Known_or_Unknown
,const std::string
& pos
, const std::string
& samplePos
, const std::string
& features
,dictionary
*d
, int *nNeg
, int *nPos
);
72 std::string
learnerCreateFeatureString(FILE *f
,mapping
*m
);
74 std::string
read_feature_list_from_config_file(FILE *f
, char *first_feature
);
75 std::string
read_feature_list_from_string(const std::vector
< std::string
>& tokens
);
76 void read_config_file(const std::string
& config_file
);
79 learner(char *modelName
);
82 void learnerRun(const std::string
& train
);