CMiniLexicon::FindMajorSignatures(): use log file routines
[linguistica.git] / CorpusWord.cpp
blob1e84e782370f4154fbcec7c6a204031a1c07b87a
1 // Implementation of CCorpusWord methods
2 // Copyright © 2009 The University of Chicago
3 #include "CorpusWord.h"
5 #include "CompoundCollection.h"
6 #include "Linker.h"
7 #include "Stem.h"
9 //--------------------------------------------------------------------
10 // Construction/Destruction
11 //--------------------------------------------------------------------
13 CCorpusWord::CCorpusWord(CMiniLexicon* lex): CLParse( lex )
15 m_morphemes.resize( m_PieceCount );
17 m_updated = FALSE;
21 CCorpusWord::CCorpusWord(const CStringSurrogate& ssCorpusWord, CMiniLexicon* lex): CLParse( ssCorpusWord, lex )
23 m_morphemes.resize( m_PieceCount );
25 m_updated = FALSE;
29 CCorpusWord::CCorpusWord(CCorpusWord& CorpusWord): CLParse( CorpusWord, NULL )
31 m_morphemes.resize( m_PieceCount );
33 m_updated = FALSE;
37 CCorpusWord::CCorpusWord(const CLParse& LParse): CLParse( LParse, LParse.GetMyMini() )
39 m_morphemes.resize( m_PieceCount );
41 m_updated = FALSE;
45 CCorpusWord::CCorpusWord(const CParse& Parse, CMiniLexicon* lex): CLParse( Parse, lex )
47 m_morphemes.resize( m_PieceCount );
49 m_updated = FALSE;
53 CCorpusWord::~CCorpusWord()
58 //-----------------------------------------------------------------
59 // Overloaded operators
60 //-----------------------------------------------------------------
62 void CCorpusWord::operator= (const CCorpusWord& RHS)
64 CopyParse(RHS);
66 m_morphemes.resize( m_PieceCount );
70 void CCorpusWord::Copy (CCorpusWord& RHS)
72 CopyParse(RHS);
74 m_morphemes.resize( m_PieceCount );
78 //--------------------------------------------------
79 // Public accessor methods
80 //--------------------------------------------------
82 CLParse* CCorpusWord::GetMorpheme( int i ) const
84 if( i > 0 && i <= Size() ) return m_morphemes[i-1];
85 else return NULL;
88 //--------------------------------------------------
89 // Public mutator methods
90 //--------------------------------------------------
92 void CCorpusWord::CutRightBeforeHere( int i )
94 CParse::CutRightBeforeHere(i);
96 m_morphemes.resize( m_PieceCount );
98 Q_ASSERT( m_LengthOfPieceVector >= Size() );
100 for( int j = Size() - 1; j > 0; j-- )
102 if( m_Pieces[j+1] > i ) m_morphemes.insert( j, m_morphemes[j-1] );
107 void CCorpusWord::MergePieces( int i )
109 for (int j = i; j < m_PieceCount - 1; ++j)
110 m_morphemes.insert( j, m_morphemes[j+1] );
111 m_morphemes.remove( m_PieceCount - 1 );
113 CParse::MergePieces(i);
114 m_morphemes.resize( m_PieceCount );
118 void CCorpusWord::SetMorpheme( int i, CLParse* pMorph )
120 if( i > 0 && i <= Size() ) m_morphemes.insert( i - 1, pMorph );
124 void CCorpusWord::SimplifyParseStructure()
126 CParse::SimplifyParseStructure();
128 m_morphemes.resize( m_PieceCount );
132 void CCorpusWord::CopyParseStructure( CCompound* other )
134 CParse::CopyParseStructure( *other );
136 StemSet* pStems;
137 CLinker* pLinker;
139 m_morphemes.resize( m_PieceCount );
141 for( int i = 1; i <= other->Size(); i++ )
143 pStems = other->GetComponent(i);
144 if( pStems ) m_morphemes.insert( i - 1, pStems->at(0) );
145 else
147 pLinker = other->GetLinker(i);
148 if( pLinker ) m_morphemes.insert( i - 1, pLinker );
149 else m_morphemes.remove(i);
155 void CCorpusWord::SetLengthOfPieceVector(int i)
157 m_LengthOfPieceVector = i;
158 m_morphemes.resize( m_PieceCount );