Go to the documentation of this file.00001 #ifndef _FORM_INFO_H
00002 #define _FORM_INFO_H
00003
00004 #include "string.h"
00005
00006 struct CMorphForm
00007 {
00008 string m_Gramcode;
00009 string m_FlexiaStr;
00010 string m_PrefixStr;
00011
00012 CMorphForm (string Gramcode, string FlexiaStr, string PrefixStr)
00013 {
00014 m_Gramcode = Gramcode;
00015 m_FlexiaStr = FlexiaStr;
00016 m_PrefixStr = PrefixStr;
00017 assert (!m_Gramcode.empty());
00018 };
00019 bool operator == (const CMorphForm& X) const
00020 {
00021 return m_Gramcode == X.m_Gramcode
00022 && m_FlexiaStr == X.m_FlexiaStr
00023 && m_PrefixStr == X.m_PrefixStr;
00024 };
00025
00026 };
00027
00028
00029
00030 struct CFlexiaModel
00031 {
00032 string m_Comments;
00033 vector<CMorphForm> m_Flexia;
00034
00035 bool operator == (const CFlexiaModel& X) const
00036 {
00037 return m_Flexia == X.m_Flexia;
00038 };
00039 bool ReadFromString(string& s);
00040 string ToString() const;
00041
00042 string get_first_flex() const;
00043 string get_first_code() const;
00044 bool has_ancode(const string& search_ancode) const;
00045
00046 };
00047
00048
00049
00050
00051 struct CAccentModel
00052 {
00053 vector<BYTE> m_Accents;
00054
00055 bool operator == (const CAccentModel& X) const
00056 {
00057 return m_Accents == X.m_Accents;
00058
00059 };
00060 bool ReadFromString(const string& s);
00061 string ToString() const;
00062 };
00063
00064
00065
00066
00067 const size_t CommonAncodeSize = 2;
00068 const WORD UnknownParadigmNo = 0xffff-1;
00069 const WORD UnknownAccentModelNo = 0xffff-1;
00070
00071 struct CLemmaInfo
00072 {
00073 WORD m_FlexiaModelNo;
00074 WORD m_AccentModelNo;
00075 char m_CommonAncode[CommonAncodeSize];
00076
00077 CLemmaInfo()
00078 {
00079 m_FlexiaModelNo = UnknownParadigmNo;
00080 m_AccentModelNo = UnknownAccentModelNo;
00081 m_CommonAncode[0] = 0;
00082 };
00083
00084 bool operator ==(const CLemmaInfo& obj) const
00085 {
00086 return ( (m_FlexiaModelNo == obj.m_FlexiaModelNo)
00087 && (m_AccentModelNo == obj.m_AccentModelNo)
00088 && !strncmp(m_CommonAncode,obj.m_CommonAncode,CommonAncodeSize)
00089 );
00090 }
00091
00092 bool operator <(const CLemmaInfo& obj) const
00093 {
00094 if (m_FlexiaModelNo != obj.m_FlexiaModelNo)
00095 return m_FlexiaModelNo < obj.m_FlexiaModelNo;
00096
00097 int res = strncmp(m_CommonAncode,obj.m_CommonAncode,CommonAncodeSize);
00098 if (res != 0)
00099 return res < 0;
00100
00101 return m_AccentModelNo < obj.m_AccentModelNo;
00102 }
00103
00104 string GetCommonAncodeIfCan() const
00105 {
00106 if (m_CommonAncode[0] == 0) return "";
00107 return string(m_CommonAncode,2);
00108 }
00109
00110 };
00111
00112
00113 extern void ReadFlexiaModels(FILE* fp, vector<CFlexiaModel>& FlexiaModels );
00114 extern void WriteFlexiaModels(FILE* out_fp, const vector<CFlexiaModel>& FlexiaModels );
00115 extern void ReadAccentModels (FILE* fp, vector<CAccentModel>& AccentModels );
00116 extern void WriteAccentModels(FILE* out_fp, const vector<CAccentModel>& AccentModels );
00117
00118 #endif