[dasher/relicence] Revert "Japanese Language Model using canna added"
- From: Gavin Henderson <ghenderson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher/relicence] Revert "Japanese Language Model using canna added"
- Date: Fri, 4 Mar 2022 17:17:54 +0000 (UTC)
commit 4878430f94877fec6fd5b3012515e92bfbc3620c
Author: Gavin Henderson <gavin henderson hotmail co uk>
Date: Thu Mar 3 15:50:10 2022 +0000
Revert "Japanese Language Model using canna added"
This reverts commit f9e6850584ab0904be8a5fcc4c798cab38551339.
Src/DasherCore/Alphabet/AlphIO.cpp | 218 +++++++--
Src/DasherCore/Alphabet/AlphIO.h | 49 +-
.../LanguageModelling/JapaneseLanguageModel.cpp | 528 ---------------------
.../LanguageModelling/JapaneseLanguageModel.h | 150 ------
Src/DasherCore/LanguageModelling/KanjiConversion.h | 47 --
.../LanguageModelling/KanjiConversionCanna.cpp | 136 ------
.../LanguageModelling/KanjiConversionCanna.h | 32 --
Src/DasherCore/LanguageModelling/Makefile.am | 20 +-
8 files changed, 232 insertions(+), 948 deletions(-)
---
diff --git a/Src/DasherCore/Alphabet/AlphIO.cpp b/Src/DasherCore/Alphabet/AlphIO.cpp
index 9b72d38a..6a00ad29 100644
--- a/Src/DasherCore/Alphabet/AlphIO.cpp
+++ b/Src/DasherCore/Alphabet/AlphIO.cpp
@@ -318,34 +318,196 @@ void CAlphIO::XmlStartHandler(const XML_Char *name, const XML_Char **atts) {
return;
}
- if(strcmp(name, "protect") == 0) {
- if (!InputInfo->EndConvertCharacter) InputInfo->EndConvertCharacter = new CAlphInfo::character();
- ReadCharAtts(atts, *(InputInfo->EndConvertCharacter));
- return;
- }
-
- if(strcmp(name, "context") == 0) {
- while(*atts != 0) {
- if(strcmp(*atts, "default") == 0) {
- InputInfo->m_strDefaultContext = *(atts+1);
- }
- atts += 2;
- }
- return;
- }
-
- if(strcmp(name, "s") == 0) {
-
- if (m_vGroups.empty()) InputInfo->iNumChildNodes++; else m_vGroups.back()->iNumChildNodes++;
- InputInfo->m_vCharacters.resize(InputInfo->m_vCharacters.size()+1);
- CAlphInfo::character &Ch(InputInfo->m_vCharacters.back());
-
- // FIXME - need to do a more sensible job of ensuring that
- // defaults are correct (plus more generally fixing behaviour when
- // incomplete/invalid XML is supplied)
- ReadCharAtts(atts, Ch);
- return;
- }
+void CAlphIO::XML_StartElement(void *userData, const XML_Char *name, const XML_Char **atts)
+{
+ CAlphIO* Me = (CAlphIO*) userData;
+
+ Me->CData = "";
+
+ if (strcmp(name, "alphabet")==0) {
+ AlphInfo NewInfo;
+ Me->InputInfo = NewInfo;
+ Me->InputInfo.Mutable = Me->LoadMutable;
+ Me->InputInfo.SpaceCharacter.Colour = -1;
+ Me->InputInfo.ParagraphCharacter.Colour = -1;
+ Me->InputInfo.ControlCharacter.Colour = -1;
+ while (*atts!=0) {
+ if (strcmp(*atts, "name")==0) {
+ atts++;
+ Me->InputInfo.AlphID = *atts;
+ atts--;
+ }
+ atts += 2;
+ }
+ return;
+ }
+
+ if (strcmp(name, "orientation")==0) {
+ while (*atts!=0) {
+ if (strcmp(*atts, "type")) {
+ atts++;
+ if (strcmp(*atts, "RL")) {
+ Me->InputInfo.Orientation = Opts::LeftToRight;
+ } else if (strcmp(*atts, "TB")) {
+ Me->InputInfo.Orientation = Opts::TopToBottom;
+ } else if (strcmp(*atts, "BT")) {
+ Me->InputInfo.Orientation = Opts::BottomToTop;
+ } else
+ Me->InputInfo.Orientation = Opts::LeftToRight;
+ atts--;
+ }
+ atts += 2;
+ }
+ return;
+ }
+
+ if (strcmp(name, "encoding")==0) {
+ while (*atts!=0) {
+ if (strcmp(*atts, "type")==0) {
+ atts++;
+ Me->InputInfo.Type = Me->StoT[*atts];
+ atts--;
+ }
+ atts += 2;
+ }
+ return;
+ }
+
+ if (strcmp(name, "space")==0) {
+ while (*atts!=0) {
+ if (strcmp(*atts, "t")==0) {
+ atts++;
+ Me->InputInfo.SpaceCharacter.Text = *atts;
+ atts--;
+ }
+ if (strcmp(*atts, "d")==0) {
+ atts++;
+ Me->InputInfo.SpaceCharacter.Display = *atts;
+ atts--;
+ }
+ if (strcmp(*atts, "b")==0) {
+ atts++;
+ Me->InputInfo.SpaceCharacter.Colour = atoi(*atts);
+ atts--;
+ }
+ if (strcmp(*atts, "f")==0) {
+ atts++;
+ Me->InputInfo.SpaceCharacter.Foreground = *atts;
+ atts--;
+ }
+ atts += 2;
+ }
+ return;
+ }
+ if (strcmp(name, "paragraph")==0) {
+ while (*atts!=0) {
+ if (strcmp(*atts, "d")==0) {
+ atts++;
+ Me->InputInfo.ParagraphCharacter.Display = *atts;
+#ifdef WIN32
+ Me->InputInfo.ParagraphCharacter.Text = "\r\n";
+#else
+ Me->InputInfo.ParagraphCharacter.Text = "\n";
+#endif
+ atts--;
+ }
+ if (strcmp(*atts, "b")==0) {
+ atts++;
+ Me->InputInfo.ParagraphCharacter.Colour = atoi(*atts);
+ atts--;
+ }
+ if (strcmp(*atts, "f")==0) {
+ atts++;
+ Me->InputInfo.ParagraphCharacter.Foreground = *atts;
+ atts--;
+ }
+ atts += 2;
+ }
+ return;
+ }
+ if (strcmp(name, "control")==0) {
+ while (*atts!=0) {
+ if (strcmp(*atts, "t")==0) {
+ atts++;
+ Me->InputInfo.ControlCharacter.Text = *atts;
+ atts--;
+ }
+ if (strcmp(*atts, "d")==0) {
+ atts++;
+ Me->InputInfo.ControlCharacter.Display = *atts;
+ atts--;
+ }
+ if (strcmp(*atts, "b")==0) {
+ atts++;
+ Me->InputInfo.ControlCharacter.Colour = atoi(*atts);
+ atts--;
+ }
+ if (strcmp(*atts, "f")==0) {
+ atts++;
+ Me->InputInfo.ControlCharacter.Foreground = *atts;
+ atts--;
+ }
+ atts += 2;
+ }
+ return;
+ }
+
+ if (strcmp(name, "group")==0) {
+ AlphInfo::group NewGroup;
+ NewGroup.Colour=-1;
+ NewGroup.Label="";
+ Me->InputInfo.Groups.push_back(NewGroup);
+ while (*atts!=0) {
+ if (strcmp(*atts, "name")==0) {
+ atts++;
+ Me->InputInfo.Groups.back().Description = *atts;
+ atts--;
+ }
+ if (strcmp(*atts, "b")==0) {
+ atts++;
+ Me->InputInfo.Groups.back().Colour = atoi(*atts);
+ atts--;
+ }
+ if (strcmp(*atts, "label")==0) {
+ atts++;
+ Me->InputInfo.Groups.back().Label = *atts;
+ atts--;
+ }
+ atts += 2;
+ }
+ return;
+ }
+
+ if (strcmp(name, "s")==0) {
+ AlphInfo::character NewCharacter;
+ NewCharacter.Colour=-1;
+ Me->InputInfo.Groups.back().Characters.push_back(NewCharacter);
+ AlphInfo::character& Ch = Me->InputInfo.Groups.back().Characters.back();
+ while (*atts!=0) {
+ if (strcmp(*atts, "t")==0) {
+ atts++;
+ Ch.Text = *atts;
+ atts--;
+ }
+ if (strcmp(*atts, "d")==0) {
+ atts++;
+ Ch.Display = *atts;
+ atts--;
+ }
+ if (strcmp(*atts, "b")==0) {
+ atts++;
+ Ch.Colour = atoi(*atts);
+ atts--;
+ }
+ if (strcmp(*atts, "f")==0) {
+ atts++;
+ Ch.Foreground = *atts;
+ atts--;
+ }
+ atts += 2;
+ }
+ return;
+ }
}
void CAlphIO::ReadCharAtts(const XML_Char **atts, CAlphInfo::character &ch) {
diff --git a/Src/DasherCore/Alphabet/AlphIO.h b/Src/DasherCore/Alphabet/AlphIO.h
index 4e4ee00b..2d8f683b 100644
--- a/Src/DasherCore/Alphabet/AlphIO.h
+++ b/Src/DasherCore/Alphabet/AlphIO.h
@@ -49,16 +49,45 @@ namespace Dasher {
/// so can create/manipulate instances.)
class Dasher::CAlphIO : public AbstractXMLParser {
public:
-
- ///Create a new AlphIO. Initially, it will have only a 'default' alphabet
- /// definition (English); further alphabets may be loaded in by calling the
- /// Parse... methods inherited from Abstract[XML]Parser
- CAlphIO(CMessageDisplay *pMsgs);
-
- virtual ~CAlphIO();
- void GetAlphabets(std::vector < std::string > *AlphabetList) const;
- std::string GetDefault();
- const CAlphInfo *GetInfo(const std::string & AlphID) const;
+ // This structure completely describes the characters used in alphabet
+ struct AlphInfo
+ {
+ // Basic information
+ std::string AlphID;
+ bool Mutable; // If from user we may play. If from system defaults this is immutable. User
should take a copy.
+
+ // Complete description of the alphabet:
+ std::string TrainingFile;
+ std::string GameModeFile;
+ std::string PreferredColours;
+ Opts::AlphabetTypes Encoding;
+ Opts::AlphabetTypes Type;
+ Opts::ScreenOrientations Orientation;
+ struct character
+ {
+ std::string Display;
+ std::string Text;
+ int Colour;
+ std::string Foreground;
+ };
+ struct group
+ {
+ std::string Description;
+ std::vector< character > Characters;
+ int Colour;
+ std::string Label;
+ };
+ std::vector< group > Groups;
+ character ParagraphCharacter; // display and edit text of paragraph character. Use ("", "") if no
paragraph character.
+ character SpaceCharacter; // display and edit text of Space character. Typically (" ", "_").
Use ("", "") if no space character.
+ character ControlCharacter; // display and edit text of Control character. Typically ("",
"Control"). Use ("", "") if no control character.
+ };
+
+ CAlphIO(std::string SystemLocation, std::string UserLocation, std::vector<std::string> Filenames);
+ void GetAlphabets(std::vector< std::string >* AlphabetList) const;
+ const AlphInfo& GetInfo(const std::string& AlphID);
+ void SetInfo(const AlphInfo& NewInfo);
+ void Delete(const std::string& AlphID);
private:
CAlphInfo::character *SpaceCharacter, *ParagraphCharacter;
std::vector<SGroupInfo *> m_vGroups;
diff --git a/Src/DasherCore/LanguageModelling/Makefile.am b/Src/DasherCore/LanguageModelling/Makefile.am
index 7b0c8cbb..fbc53145 100644
--- a/Src/DasherCore/LanguageModelling/Makefile.am
+++ b/Src/DasherCore/LanguageModelling/Makefile.am
@@ -1,19 +1,5 @@
noinst_LTLIBRARIES = libdasherlm.la
-libdasherlm_la_SOURCES = \
- CTWLanguageModel.cpp \
- CTWLanguageModel.h \
- DictLanguageModel.cpp \
- DictLanguageModel.h \
- HashTable.cpp \
- HashTable.h \
- LanguageModel.h \
- MixtureLanguageModel.h \
- PPMLanguageModel.cpp \
- PPMLanguageModel.h \
- PPMPYLanguageModel.cpp \
- PPMPYLanguageModel.h \
- RoutingPPMLanguageModel.cpp \
- RoutingPPMLanguageModel.h \
- WordLanguageModel.cpp \
- WordLanguageModel.h
+noinst_LIBRARIES = libdasherlm.a
+libdasherlm_a_SOURCES = PPMLanguageModel.cpp WordLanguageModel.cpp DictLanguageModel.cpp LanguageModel.cpp
+AM_CXXFLAGS = -O2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]