1 // Driver and result type for alignment of similar signatures
2 // Copyright © 2009 The University of Chicago
10 #include "MiniLexicon.h"
12 enum eAlignmentStatus
{IDENTICAL
, DIFFERENT
};
14 class AffixAlignment
{
15 QString m_OriginalAffix1
;
16 QString m_OriginalAffix2
;
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
;
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.
41 // disable default-construction
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
;
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
74 CSignatureAlignment();
75 CSignatureAlignment(const CSignatureAlignment
& x
);
76 CSignatureAlignment
& operator=(const CSignatureAlignment
& x
);
79 // Levenshtein’s string-edit-distance algorithm
81 void FindBestAlignment();
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();
94 void Display(QTextStream
& LogStream
);
95 void Display(CMiniLexicon
* p_mini
);
98 #endif // ALLOMORPHY_H