CMiniLexicon::FindMajorSignatures(): use log file routines
[linguistica.git] / Stem_EncodingLength.cpp
blob3a8f0a23afbb6b982283c69f2614178787f49fcf
1 // Implementation of CStem description length methods
2 // Copyright © 2009 The University of Chicago
3 #include "Stem.h"
4 #include "MiniLexicon.h"
5 #include "Lexicon.h"
6 #include "StemCollection.h"
7 #include "log2.h"
9 double CStem::GetLengthOfPointerToMe() const
11 if (m_LengthOfPointerToMe > 0)
12 return m_LengthOfPointerToMe;
13 m_LengthOfPointerToMe = log2(m_pMyMini->GetStems()->GetCorpusCount() /
14 GetCorpusCount());
15 return m_LengthOfPointerToMe;
18 double CStem::GetLengthOfPointerToMe_2()
19 { return GetLengthOfPointerToMe(); }
21 double CStem::GetPhonologicalInformationContent(CLexicon* MotherLexicon) const
23 if (m_PhonologicalContent != 0.0)
24 return m_PhonologicalContent;
26 if (MotherLexicon != 0)
27 CalculatePhonologicalInformationContent(MotherLexicon);
28 return m_PhonologicalContent;
31 double CStem::CalculatePhonologicalInformationContent(CLexicon* Lexicon) const
33 m_PhonologicalContent = m_BigramLogProb > 0.0 ?
34 m_BigramLogProb :
35 CParse::ComputeDL(Lexicon->GetNumberOfCharacterTypes());
36 return m_PhonologicalContent;
39 // Calculate the description length
41 // Returns:
42 // float - the descrition length
43 float CStem::CalculateDL() const
45 static const float PointerLength = log2(float(27.0));
46 return PointerLength * GetKeyLength();