This commit is contained in:
Hieu Hoang 2014-02-22 20:56:20 +00:00
parent c736c81701
commit bd7e5e3e7e
3 changed files with 39 additions and 5 deletions

View File

@ -7,6 +7,7 @@
#include <sstream>
#include <cassert>
#include "ConsistentPhrases.h"
#include "NonTerm.h"
using namespace std;
@ -32,11 +33,17 @@ void ConsistentPhrases::Add(int sourceStart, int sourceEnd,
int targetStart, int targetEnd)
{
Coll &coll = m_coll[sourceStart][sourceEnd - sourceEnd];
ConsistentPhrase cp(sourceStart,
ConsistentPhrase cpInsert(sourceStart,
sourceEnd,
targetStart,
targetEnd);
coll[cp] = NonTerms();
NonTerms nonTermsInsert;
pair<Coll::iterator,bool> inserted = coll.insert(pair<ConsistentPhrase, NonTerms>(cpInsert, nonTermsInsert));
const ConsistentPhrase &cp = inserted.first->first;
NonTerms &nonTerms = inserted.first->second;
NonTerm *nt = new NonTerm(cp, "[XXXX]", "[XXXX]");
nonTerms.push_back(nt);
}
const ConsistentPhrases::Coll &ConsistentPhrases::GetColl(int sourceStart, int sourceEnd) const

View File

@ -5,10 +5,18 @@
* Author: hieu
*/
#include <NonTerm.h>
#include <sstream>
#include "NonTerm.h"
#include "Word.h"
NonTerm::NonTerm(const ConsistentPhrase &consistentPhrase)
using namespace std;
NonTerm::NonTerm(const ConsistentPhrase &consistentPhrase,
const std::string &source,
const std::string &target)
:m_consistentPhrase(consistentPhrase)
,m_source(source)
,m_target(target)
{
// TODO Auto-generated constructor stub
@ -18,3 +26,15 @@ NonTerm::~NonTerm() {
// TODO Auto-generated destructor stub
}
std::string NonTerm::Debug() const
{
stringstream out;
out << m_source << m_target;
return out.str();
}
void NonTerm::Output(std::ostream &out) const
{
out << m_source << m_target;
}

View File

@ -5,6 +5,7 @@
* Author: hieu
*/
#pragma once
#include <string>
#include "RuleSymbol.h"
class ConsistentPhrase;
@ -12,13 +13,19 @@ class ConsistentPhrase;
class NonTerm : public RuleSymbol
{
public:
NonTerm(const ConsistentPhrase &consistentPhrase);
NonTerm(const ConsistentPhrase &consistentPhrase,
const std::string &source,
const std::string &target);
virtual ~NonTerm();
const ConsistentPhrase &GetConsistentPhrase()
{ return m_consistentPhrase; }
virtual std::string Debug() const;
virtual void Output(std::ostream &out) const;
protected:
const ConsistentPhrase &m_consistentPhrase;
std::string m_source, m_target;
};