mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-10-05 15:58:03 +03:00
Ongoing moses/phrase-extract refactoring
This commit is contained in:
parent
2f735998ca
commit
985e7bbfc3
@ -28,7 +28,7 @@
|
||||
|
||||
#include "RuleExtractionOptions.h"
|
||||
#include "SentenceAlignment.h"
|
||||
#include "SyntaxTree.h"
|
||||
#include "SyntaxNodeCollection.h"
|
||||
|
||||
namespace MosesTraining
|
||||
{
|
||||
|
75
phrase-extract/SyntaxNode.h
Normal file
75
phrase-extract/SyntaxNode.h
Normal file
@ -0,0 +1,75 @@
|
||||
/***********************************************************************
|
||||
Moses - factored phrase-based language decoder
|
||||
Copyright (C) 2009 University of Edinburgh
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
***********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace MosesTraining
|
||||
{
|
||||
|
||||
class SyntaxNode
|
||||
{
|
||||
protected:
|
||||
int m_start, m_end;
|
||||
std::string m_label;
|
||||
std::vector< SyntaxNode* > m_children;
|
||||
SyntaxNode* m_parent;
|
||||
float m_pcfgScore;
|
||||
public:
|
||||
SyntaxNode( int startPos, int endPos, std::string label )
|
||||
:m_start(startPos)
|
||||
,m_end(endPos)
|
||||
,m_label(label)
|
||||
,m_parent(0)
|
||||
,m_pcfgScore(0.0f) {
|
||||
}
|
||||
int GetStart() const {
|
||||
return m_start;
|
||||
}
|
||||
int GetEnd() const {
|
||||
return m_end;
|
||||
}
|
||||
std::string GetLabel() const {
|
||||
return m_label;
|
||||
}
|
||||
float GetPcfgScore() const {
|
||||
return m_pcfgScore;
|
||||
}
|
||||
void SetPcfgScore(float score) {
|
||||
m_pcfgScore = score;
|
||||
}
|
||||
SyntaxNode *GetParent() {
|
||||
return m_parent;
|
||||
}
|
||||
void SetParent(SyntaxNode *parent) {
|
||||
m_parent = parent;
|
||||
}
|
||||
void AddChild(SyntaxNode* child) {
|
||||
m_children.push_back(child);
|
||||
}
|
||||
const std::vector< SyntaxNode* > &GetChildren() const {
|
||||
return m_children;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace MosesTraining
|
@ -18,7 +18,7 @@
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
#include "SyntaxTree.h"
|
||||
#include "SyntaxNodeCollection.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
@ -42,7 +42,8 @@ void SyntaxNodeCollection::Clear()
|
||||
m_index.clear();
|
||||
}
|
||||
|
||||
SyntaxNode *SyntaxNodeCollection::AddNode( int startPos, int endPos, std::string label )
|
||||
SyntaxNode *SyntaxNodeCollection::AddNode(int startPos, int endPos,
|
||||
const std::string &label)
|
||||
{
|
||||
SyntaxNode* newNode = new SyntaxNode( startPos, endPos, label );
|
||||
m_nodes.push_back( newNode );
|
||||
@ -151,4 +152,4 @@ void SyntaxNodeCollection::ConnectNodes()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace MosesTraining
|
@ -24,55 +24,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "SyntaxNode.h"
|
||||
|
||||
namespace MosesTraining
|
||||
{
|
||||
|
||||
class SyntaxNode
|
||||
{
|
||||
protected:
|
||||
int m_start, m_end;
|
||||
std::string m_label;
|
||||
std::vector< SyntaxNode* > m_children;
|
||||
SyntaxNode* m_parent;
|
||||
float m_pcfgScore;
|
||||
public:
|
||||
SyntaxNode( int startPos, int endPos, std::string label )
|
||||
:m_start(startPos)
|
||||
,m_end(endPos)
|
||||
,m_label(label)
|
||||
,m_parent(0)
|
||||
,m_pcfgScore(0.0f) {
|
||||
}
|
||||
int GetStart() const {
|
||||
return m_start;
|
||||
}
|
||||
int GetEnd() const {
|
||||
return m_end;
|
||||
}
|
||||
std::string GetLabel() const {
|
||||
return m_label;
|
||||
}
|
||||
float GetPcfgScore() const {
|
||||
return m_pcfgScore;
|
||||
}
|
||||
void SetPcfgScore(float score) {
|
||||
m_pcfgScore = score;
|
||||
}
|
||||
SyntaxNode *GetParent() {
|
||||
return m_parent;
|
||||
}
|
||||
void SetParent(SyntaxNode *parent) {
|
||||
m_parent = parent;
|
||||
}
|
||||
void AddChild(SyntaxNode* child) {
|
||||
m_children.push_back(child);
|
||||
}
|
||||
const std::vector< SyntaxNode* > &GetChildren() const {
|
||||
return m_children;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef std::vector< int > SplitPoints;
|
||||
typedef std::vector< SplitPoints > ParentNodes;
|
||||
|
||||
@ -97,7 +53,7 @@ public:
|
||||
|
||||
~SyntaxNodeCollection();
|
||||
|
||||
SyntaxNode *AddNode( int startPos, int endPos, std::string label );
|
||||
SyntaxNode *AddNode( int startPos, int endPos, const std::string &label );
|
||||
|
||||
SyntaxNode *GetTop() {
|
||||
return m_top;
|
@ -24,7 +24,8 @@
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
#include "SyntaxTree.h"
|
||||
|
||||
#include "SyntaxNodeCollection.h"
|
||||
#include "XmlException.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -1,6 +1,3 @@
|
||||
// $Id: XmlOption.cpp 1960 2008-12-15 12:52:38Z phkoehn $
|
||||
// vim:tabstop=2
|
||||
|
||||
/***********************************************************************
|
||||
Moses - factored phrase-based language decoder
|
||||
Copyright (C) 2006 University of Edinburgh
|
||||
@ -21,11 +18,13 @@
|
||||
***********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include "SyntaxTree.h"
|
||||
|
||||
#include "SyntaxNodeCollection.h"
|
||||
|
||||
namespace MosesTraining
|
||||
{
|
||||
@ -39,5 +38,4 @@ bool ProcessAndStripXMLTags(std::string &line, SyntaxNodeCollection &tree, std::
|
||||
std::string unescape(const std::string &str);
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace MosesTraining
|
||||
|
@ -33,7 +33,8 @@
|
||||
#include "Span.h"
|
||||
#include "StsgRule.h"
|
||||
#include "StsgRuleWriter.h"
|
||||
#include "SyntaxTree.h"
|
||||
#include "SyntaxNode.h"
|
||||
#include "SyntaxNodeCollection.h"
|
||||
#include "tables-core.h"
|
||||
#include "XmlException.h"
|
||||
#include "XmlTree.h"
|
||||
|
@ -19,11 +19,12 @@
|
||||
|
||||
#include "ScfgRule.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "Node.h"
|
||||
#include "Subgraph.h"
|
||||
#include "SyntaxTree.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "SyntaxNode.h"
|
||||
#include "SyntaxNodeCollection.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
|
@ -19,16 +19,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Alignment.h"
|
||||
#include "Rule.h"
|
||||
#include "SyntaxTree.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
|
||||
#include "Alignment.h"
|
||||
#include "Rule.h"
|
||||
#include "SyntaxNodeCollection.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
namespace GHKM
|
||||
@ -95,4 +95,3 @@ private:
|
||||
|
||||
} // namespace GHKM
|
||||
} // namespace Moses
|
||||
|
||||
|
@ -23,14 +23,15 @@
|
||||
|
||||
#include "Exception.h"
|
||||
|
||||
#include "SyntaxTree.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "SyntaxNode.h"
|
||||
#include "SyntaxNodeCollection.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
namespace GHKM
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "HoleCollection.h"
|
||||
#include "RuleExist.h"
|
||||
#include "SentenceAlignmentWithSyntax.h"
|
||||
#include "SyntaxTree.h"
|
||||
#include "SyntaxNode.h"
|
||||
#include "tables-core.h"
|
||||
#include "XmlTree.h"
|
||||
#include "InputFileStream.h"
|
||||
|
@ -28,7 +28,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "pcfg_tree.h"
|
||||
#include "SyntaxTree.h"
|
||||
#include "SyntaxNode.h"
|
||||
#include "SyntaxNodeCollection.h"
|
||||
|
||||
namespace MosesTraining {
|
||||
namespace Syntax {
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "SyntaxTree.h"
|
||||
#include "SyntaxNodeCollection.h"
|
||||
#include "XmlTree.h"
|
||||
|
||||
#define LINE_MAX_LENGTH 1000000
|
||||
|
@ -5,7 +5,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "SyntaxTree.h"
|
||||
#include "SyntaxNode.h"
|
||||
#include "SyntaxNodeCollection.h"
|
||||
|
||||
#include "exception.h"
|
||||
#include "string_tree.h"
|
||||
|
Loading…
Reference in New Issue
Block a user