CMiniLexicon::FindMajorSignatures(): use log file routines
[linguistica.git] / Allomorphy.h
blob9a563b7ca51155254dccd4aba288cbd585854222
1 // Driver and result type for alignment of similar signatures
2 // Copyright © 2009 The University of Chicago
3 #ifndef ALLOMORPHY_H
4 #define ALLOMORPHY_H
6 #include <QTextStream>
7 #include <QList>
8 #include <QStringList>
9 #include "Parse.h"
10 #include "MiniLexicon.h"
12 enum eAlignmentStatus {IDENTICAL, DIFFERENT};
14 class AffixAlignment {
15 QString m_OriginalAffix1;
16 QString m_OriginalAffix2;
17 QString m_Affix1;
18 QString m_Affix2;
19 QString m_Margin1;
20 QString m_Margin2;
21 QString m_Shift1;
22 QString m_Shift2;
23 enum eAlignmentStatus m_Status;
24 /// size in bits of overlap of letters/phonemes
25 double m_Agreement_unigram;
26 /// size in bits of overlap of bigram-letters/phonemes
27 double m_Agreement_bigram;
28 /// size in bits of symmetric difference.
29 double m_Disagreement_unigram;
30 double m_Disagreement_bigram;
31 public:
32 // construction/destruction.
34 AffixAlignment(QString Affix1, QString Affix2);
35 AffixAlignment(QString Margin1, QString Affix1,
36 QString Margin2, QString Affix2);
37 // destructor implicitly defined.
39 // copy-construction and assignment implicitly defined.
40 private:
41 // disable default-construction
42 AffixAlignment();
43 public:
44 // aligned affixes.
46 QString GetAffix1() const { return m_Affix1;}
47 QString GetAffix2() const { return m_Affix2;}
48 QString GetMargin1() const { return m_Margin1;}
49 QString GetMargin2() const { return m_Margin2;}
50 QString GetShift1() const { return m_Shift1;}
51 QString GetShift2() const { return m_Shift2;}
54 /// m_Sig1 is shorter than m_Sig2, or of same length, where we measure length as the total number of letters in the K longest affixes, where K is the min of the length of the two signatures.
55 class CSignatureAlignment {
56 class CSignature* m_SigPtr1;
57 class CSignature* m_SigPtr2;
58 QList<AffixAlignment*> m_AffixAlignments;
59 QStringList m_Sig1AlignedAffixes;
60 QStringList m_Sig2AlignedAffixes;
61 CSignature* m_LongerSig;
62 CSignature* m_ShorterSig;
63 QString m_difference;
64 public:
65 // construction/destruction.
67 CSignatureAlignment(class CSignature* Sig1, class CSignature* Sig2);
68 CSignature* LongerSig() {return m_LongerSig;};
69 QString difference() {return m_difference;};
70 // destructor implicitly defined
72 // disable default-construction, copy
73 private:
74 CSignatureAlignment();
75 CSignatureAlignment(const CSignatureAlignment& x);
76 CSignatureAlignment& operator=(const CSignatureAlignment& x);
77 public:
79 // Levenshtein’s string-edit-distance algorithm
81 void FindBestAlignment();
82 /// success?
83 bool AllSig1AffixesAligned();
84 bool AllSig2AffixesAligned();
85 /// result from string-edit-distance algorithm
86 QList<AffixAlignment*>* GetAffixAlignments()
87 { return &m_AffixAlignments; }
89 /// Determines whether the two suffix signatures differ just by one having a prefix that the other does not (e.g., t, or at)
90 bool FindWhetherOneIsSuffixOfTheOther();
93 /// output to file
94 void Display(QTextStream& LogStream);
95 void Display(CMiniLexicon* p_mini);
98 #endif // ALLOMORPHY_H