Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzens <zens@1f5c12ca-751b-0410-a591-d2e778427230>2006-07-21 21:43:42 +0400
committerzens <zens@1f5c12ca-751b-0410-a591-d2e778427230>2006-07-21 21:43:42 +0400
commit70682b48a1f4d6a3723c3daf6cd212fe0e068eb9 (patch)
treefe3c81f051189f4bd8738cf9c5cb6d65b0cc55bd /moses-cmd
parent8fcc3451fa0b0c7b8006f65df8d3690ff8cc1df8 (diff)
- prepare I/O for Confusion Nets
- remove some of the dynamic casting stuff git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@245 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'moses-cmd')
-rwxr-xr-xmoses-cmd/src/IOCommandLine.cpp12
-rwxr-xr-xmoses-cmd/src/IOCommandLine.h24
-rwxr-xr-xmoses-cmd/src/IOFile.cpp24
-rwxr-xr-xmoses-cmd/src/IOFile.h2
-rwxr-xr-xmoses-cmd/src/IOMySQL.cpp2
-rwxr-xr-xmoses-cmd/src/IOMySQL.h2
-rw-r--r--moses-cmd/src/Main.cpp2
7 files changed, 24 insertions, 44 deletions
diff --git a/moses-cmd/src/IOCommandLine.cpp b/moses-cmd/src/IOCommandLine.cpp
index d6b3b62fc..a035c3fb8 100755
--- a/moses-cmd/src/IOCommandLine.cpp
+++ b/moses-cmd/src/IOCommandLine.cpp
@@ -58,17 +58,9 @@ IOCommandLine::IOCommandLine(
}
}
-Sentence *IOCommandLine::GetInput()
+InputType*IOCommandLine::GetInput(InputType* in)
{
- static long sentenceId = 0;
-
- Sentence *sentence;
- if ((sentence = ::GetInput(cin, m_factorOrder, m_factorCollection)) != NULL)
- {
- sentence->SetTranslationId(sentenceId++);
- }
-
- return sentence;
+ return InputOutput::GetInput(in,std::cin,m_factorOrder, m_factorCollection);
}
// help fn
diff --git a/moses-cmd/src/IOCommandLine.h b/moses-cmd/src/IOCommandLine.h
index 41f7a8c14..9ae931340 100755
--- a/moses-cmd/src/IOCommandLine.h
+++ b/moses-cmd/src/IOCommandLine.h
@@ -58,31 +58,27 @@ public:
, size_t nBestSize
, const std::string &nBestFilePath);
- Sentence *GetInput();
+ InputType* GetInput(InputType*);
void SetOutput(const Hypothesis *hypo, long translationId);
void SetNBest(const LatticePathList &nBestList, long translationId);
void Backtrack(const Hypothesis *hypo);
};
-
+#if 0
// help fn
inline Sentence *GetInput(std::istream &inputStream
, const std::vector<FactorType> &factorOrder
, FactorCollection &factorCollection)
{
- std::string line;
- do
- {
- if (getline(inputStream, line, '\n').eof())
- {
- return NULL;
- }
- boost::trim(line);
- } while (line == "");
- Sentence *sentence = new Sentence(Input);
- sentence->CreateFromString(factorOrder, line, factorCollection);
- return sentence;
+ return dynamic_cast<Sentence*>(GetInput(new Sentence(Input),inputStream,factorOrder,factorCollection));
+#if 0
+ Sentence *rv=new Sentence(Input);
+ if(rv->Read(inputStream,factorOrder,factorCollection))
+ return rv;
+ else {delete rv; return 0;}
+#endif
}
+#endif
diff --git a/moses-cmd/src/IOFile.cpp b/moses-cmd/src/IOFile.cpp
index 058d87845..c981a851d 100755
--- a/moses-cmd/src/IOFile.cpp
+++ b/moses-cmd/src/IOFile.cpp
@@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
// example file on how to use moses library
#include "IOFile.h"
-
+#include "Sentence.h"
using namespace std;
IOFile::IOFile(const std::vector<FactorType> &factorOrder
@@ -48,26 +48,18 @@ IOFile::IOFile(const std::vector<FactorType> &factorOrder
{
}
-Sentence *IOFile::GetInput()
+InputType* IOFile::GetInput(InputType* in)
{
- static long sentenceId = 0;
- Sentence *sentence;
- if ((sentence = ::GetInput(m_inputFile, m_factorOrder, m_factorCollection)) != NULL)
- {
- sentence->SetTranslationId(sentenceId++);
- }
-
- return sentence;
+ return InputOutput::GetInput(in,m_inputFile, m_factorOrder, m_factorCollection);
}
void IOFile::GetInputPhrase(std::list<Phrase> &inputPhraseList)
{
ifstream inputFile(m_inputFilePath.c_str());
- Sentence *sentence;
- while ((sentence = ::GetInput(inputFile, m_factorOrder, m_factorCollection)) != NULL)
- {
- inputPhraseList.push_back(*sentence);
- Release(sentence);
- }
+ while(Sentence *sentence=dynamic_cast<Sentence*>(InputOutput::GetInput(new Sentence(Input),inputFile, m_factorOrder, m_factorCollection)))
+ {
+ inputPhraseList.push_back(*sentence);
+ Release(sentence);
+ }
}
diff --git a/moses-cmd/src/IOFile.h b/moses-cmd/src/IOFile.h
index 87e7a58d5..46dc3d41e 100755
--- a/moses-cmd/src/IOFile.h
+++ b/moses-cmd/src/IOFile.h
@@ -53,7 +53,7 @@ public:
, const std::string &nBestFilePath
, const std::string &inputFilePath);
- Sentence *GetInput();
+ InputType *GetInput(InputType*);
void GetInputPhrase(std::list<Phrase> &inputPhraseList);
};
diff --git a/moses-cmd/src/IOMySQL.cpp b/moses-cmd/src/IOMySQL.cpp
index ed3216c78..338007647 100755
--- a/moses-cmd/src/IOMySQL.cpp
+++ b/moses-cmd/src/IOMySQL.cpp
@@ -97,7 +97,7 @@ void IOMySQL::Connect(mysqlpp::Connection &conn)
}
}
-Sentence *IOMySQL::GetInput()
+InputType *IOMySQL::GetInput(InputType*)
{
TRACE_ERR("boo" << endl);
//return m_threadMySQL->GetSentence();
diff --git a/moses-cmd/src/IOMySQL.h b/moses-cmd/src/IOMySQL.h
index e12503ef7..7c96ea145 100755
--- a/moses-cmd/src/IOMySQL.h
+++ b/moses-cmd/src/IOMySQL.h
@@ -68,7 +68,7 @@ public:
, FactorCollection &factorCollection);
~IOMySQL();
void Connect(mysqlpp::Connection &conn);
- Sentence *GetInput();
+ InputType *GetInput(InputType*);
void SetOutput(const Hypothesis *hypo, long translationId);
void SetNBest(const LatticePathList &nBestList, long translationId)
{
diff --git a/moses-cmd/src/Main.cpp b/moses-cmd/src/Main.cpp
index 84de31d29..89d11cdab 100644
--- a/moses-cmd/src/Main.cpp
+++ b/moses-cmd/src/Main.cpp
@@ -97,7 +97,7 @@ int main(int argc, char* argv[])
return EXIT_FAILURE;
// read each sentence & decode
- while(InputType *source = inputOutput->GetInput())
+ while(InputType *source = inputOutput->GetInput(new Sentence(Input)))
{
if(Sentence* sent=dynamic_cast<Sentence*>(source)) TRACE_ERR(*sent<<"\n");
TranslationOptionCollection *translationOptionCollection=CreateTranslationOptionCollection(source);