1 /***************************************************************************
2  *  Copyright 1991, 1992, 1993, 1994, 1995, 1996, 2001, 2002               *
3  *    David R. Hill, Leonard Manzara, Craig Schock                         *
4  *                                                                         *
5  *  This program is free software: you can redistribute it and/or modify   *
6  *  it under the terms of the GNU General Public License as published by   *
7  *  the Free Software Foundation, either version 3 of the License, or      *
8  *  (at your option) any later version.                                    *
9  *                                                                         *
10  *  This program is distributed in the hope that it will be useful,        *
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
13  *  GNU General Public License for more details.                           *
14  *                                                                         *
15  *  You should have received a copy of the GNU General Public License      *
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
17  ***************************************************************************/
18 // 2014-09
19 // This file was copied from Gnuspeech and modified by Marcelo Y. Matuda.
20 
21 #ifndef EN_PHONETIC_STRING_PARSER_H_
22 #define EN_PHONETIC_STRING_PARSER_H_
23 
24 #include <memory>
25 
26 #include "Controller.h"
27 
28 
29 
30 namespace GS {
31 namespace En {
32 
33 class PhoneticStringParser {
34 public:
35 	PhoneticStringParser(const char* configDirPath, TRMControlModel::Controller& controller);
36 	~PhoneticStringParser();
37 
38 	int parseString(const char* string);
39 private:
40 	PhoneticStringParser(const PhoneticStringParser&) = delete;
41 	PhoneticStringParser& operator=(const PhoneticStringParser&) = delete;
42 
43 	struct RewriterData {
44 		int currentState;
45 		const TRMControlModel::Posture* lastPosture;
RewriterDataRewriterData46 		RewriterData() : currentState(0), lastPosture(nullptr) {}
47 	};
48 
49 	void initVowelTransitions(const char* configDirPath);
50 	void printVowelTransitions();
51 	const TRMControlModel::Posture* rewrite(const TRMControlModel::Posture& nextPosture, int wordMarker, RewriterData& data);
52 	const TRMControlModel::Posture* calcVowelTransition(const TRMControlModel::Posture& nextPosture, RewriterData& data);
53 	std::shared_ptr<TRMControlModel::Category> getCategory(const char* name);
54 	const TRMControlModel::Posture* getPosture(const char* name);
55 
56 	const TRMControlModel::Model& model_;
57 	TRMControlModel::EventList& eventList_;
58 	std::shared_ptr<const TRMControlModel::Category> category_[18];
59 	const TRMControlModel::Posture* returnPhone_[7];
60 	int vowelTransitions_[13][13];
61 };
62 
63 } /* namespace En */
64 } /* namespace GS */
65 
66 #endif /* EN_PHONETIC_STRING_PARSER_H_ */
67