From 6ee89748f658b734aab5e8ab4cd127ec9eb38559 Mon Sep 17 00:00:00 2001 From: hieuhoang1972 Date: Tue, 14 Sep 2010 14:05:00 +0000 Subject: [PATCH] mira git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/branches/mira-mtm5@3435 1f5c12ca-751b-0410-a591-d2e778427230 --- moses-chart-cmd/src/Main.cpp | 5 +++++ moses/moses.xcodeproj/project.pbxproj | 8 ++++++++ moses/src/OnlineCommand.cpp | 3 ++- moses/src/StaticData.h | 6 +++++- moses/src/Util.h | 27 +++++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/moses-chart-cmd/src/Main.cpp b/moses-chart-cmd/src/Main.cpp index c19309086..d733cb031 100644 --- a/moses-chart-cmd/src/Main.cpp +++ b/moses-chart-cmd/src/Main.cpp @@ -138,6 +138,11 @@ int main(int argc, char* argv[]) while((line = ioWrapper->GetInput()) != "") { line += "\n"; + //if () + { + + } + ReadInput(*ioWrapper,staticData.GetInputType(),source, line); StaticData &ss = StaticData::InstanceNonConst(); diff --git a/moses/moses.xcodeproj/project.pbxproj b/moses/moses.xcodeproj/project.pbxproj index bb89e4067..4b1976e8e 100644 --- a/moses/moses.xcodeproj/project.pbxproj +++ b/moses/moses.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 1E059677123FB1E900D39289 /* OnlineCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E059675123FB1E900D39289 /* OnlineCommand.cpp */; }; + 1E059678123FB1E900D39289 /* OnlineCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E059676123FB1E900D39289 /* OnlineCommand.h */; }; 1E5D8E0411F25F03000F027F /* PhraseDictionaryNodeSCFG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E5D8E0211F25F03000F027F /* PhraseDictionaryNodeSCFG.cpp */; }; 1E5D8E0511F25F03000F027F /* PhraseDictionaryNodeSCFG.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E5D8E0311F25F03000F027F /* PhraseDictionaryNodeSCFG.h */; }; 1E5D8E0811F25F2F000F027F /* PhraseDictionarySCFG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E5D8E0611F25F2F000F027F /* PhraseDictionarySCFG.cpp */; }; @@ -224,6 +226,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 1E059675123FB1E900D39289 /* OnlineCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OnlineCommand.cpp; path = src/OnlineCommand.cpp; sourceTree = ""; }; + 1E059676123FB1E900D39289 /* OnlineCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OnlineCommand.h; path = src/OnlineCommand.h; sourceTree = ""; }; 1E5D8E0211F25F03000F027F /* PhraseDictionaryNodeSCFG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PhraseDictionaryNodeSCFG.cpp; path = src/PhraseDictionaryNodeSCFG.cpp; sourceTree = ""; }; 1E5D8E0311F25F03000F027F /* PhraseDictionaryNodeSCFG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PhraseDictionaryNodeSCFG.h; path = src/PhraseDictionaryNodeSCFG.h; sourceTree = ""; }; 1E5D8E0611F25F2F000F027F /* PhraseDictionarySCFG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PhraseDictionarySCFG.cpp; path = src/PhraseDictionarySCFG.cpp; sourceTree = ""; }; @@ -467,6 +471,8 @@ 08FB7795FE84155DC02AAC07 /* Source */ = { isa = PBXGroup; children = ( + 1E059675123FB1E900D39289 /* OnlineCommand.cpp */, + 1E059676123FB1E900D39289 /* OnlineCommand.h */, 1ED4FC5F11BDC0D2004E826A /* AlignmentInfo.cpp */, 1ED4FC6011BDC0D2004E826A /* AlignmentInfo.h */, 1ED4FC6111BDC0D2004E826A /* BilingualDynSuffixArray.cpp */, @@ -830,6 +836,7 @@ 1EF549B612118A4A00C481EB /* LanguageModelDelegate.h in Headers */, 1EF549BA12118A5D00C481EB /* TranslationSystem.h in Headers */, 1E7739D1123F646800B88EB7 /* FeatureVector.h in Headers */, + 1E059678123FB1E900D39289 /* OnlineCommand.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -977,6 +984,7 @@ 1EF549B112118A0C00C481EB /* DecodeFeature.cpp in Sources */, 1EF549B912118A5D00C481EB /* TranslationSystem.cpp in Sources */, 1E7739D0123F646800B88EB7 /* FeatureVector.cpp in Sources */, + 1E059677123FB1E900D39289 /* OnlineCommand.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/moses/src/OnlineCommand.cpp b/moses/src/OnlineCommand.cpp index a5cbf7876..3485b80d5 100644 --- a/moses/src/OnlineCommand.cpp +++ b/moses/src/OnlineCommand.cpp @@ -82,7 +82,8 @@ void OnlineCommand::Execute() const { std::cerr << "void OnlineCommand::Execute() const" << std::endl; VERBOSE(3,"OnlineCommand::Execute() const" << std::endl); - StaticData &staticData = (StaticData&) StaticData::Instance(); + + StaticData &staticData = StaticData::InstanceNonConst(); VERBOSE(1,"Handling online command: " << COMMAND_KEYWORD << " " << command_type << " " << command_value << std::endl); // weights diff --git a/moses/src/StaticData.h b/moses/src/StaticData.h index 677010c15..8316f857f 100644 --- a/moses/src/StaticData.h +++ b/moses/src/StaticData.h @@ -542,7 +542,11 @@ public: bool ContinuePartialTranslation() const { return m_continuePartialTranslation; } void ReLoadParameter(); - + Parameter* GetParameter() + { + return m_parameter; + } + }; } diff --git a/moses/src/Util.h b/moses/src/Util.h index 3e31ec197..1d587ef44 100644 --- a/moses/src/Util.h +++ b/moses/src/Util.h @@ -350,6 +350,33 @@ double GetUserTime(); // dump SGML parser for tags std::map ProcessAndStripSGML(std::string &line); +/** + * Returns the first string bounded by the delimiters (default delimiters are " " and "\t")i starting from position first_pos + * and and stores the starting position of the next string (in first_str) + */ +inline std::string GetFirstString(const std::string& str, int& first_pos, const std::string& delimiters = " \t") +{ + + std::string first_str; + // Skip delimiters at beginning. + std::string::size_type lastPos = str.find_first_not_of(delimiters, first_pos); + + // Find first "non-delimiter". + std::string::size_type pos = str.find_first_of(delimiters, lastPos); + + if (std::string::npos != pos || std::string::npos != lastPos){ + + first_str = str.substr(lastPos, pos - lastPos); + + // Skip delimiters. Note the "not_of" + lastPos = str.find_first_not_of(delimiters, pos); + + } + + first_pos = lastPos; + return first_str; +} + } #endif