CMiniLexicon::FindMajorSignatures(): use log file routines
[linguistica.git] / Alignment.h
blob6c927b80dc6ac1dd60a69ae62200956d28995d31
1 // alignment result from string-edit distance algorithm
2 // Copyright © 2009 The University of Chicago
3 #ifndef ALIGNMENT_H
4 #define ALIGNMENT_H
6 class CParse;
8 /// an alignment of two strings, Str1 and Str2.
9 /// There's an array for each string, Match1 and Match2, and they
10 /// explain how that letter lines up with its counterpart on the opposite
11 /// string. "-1" means there is no match. A non-negative number is the
12 /// index of the character to which it's aligned or matched on the
13 /// other string.
14 class CAlignment {
15 public:
16 // These are parses, so that we can cut them into
17 // pieces, based on where the alignments change qualitatively
18 // (where the slips begin or end).
19 CParse* m_Str1;
20 CParse* m_Str2;
21 int m_Length1;
22 int m_Length2;
23 int* m_Match1; // "-1" means no match
24 int* m_Match2;
25 float m_Score;
26 // number of times the alignment departs from
27 // 1-to-1 alignment. Two or more non-alignments counts as 1 slip.
28 int m_Slips;
29 // How many continuous regions of good or bad associations there are.
30 int m_Spans;
31 int m_Identities;
32 public:
33 // construction/destruction.
35 CAlignment(class QString String1, class QString String2);
36 CAlignment(CParse*, CParse*);
37 /// deprecated
38 CAlignment(const CAlignment*);
39 virtual ~CAlignment();
41 // copy.
43 CAlignment(const CAlignment& other);
44 CAlignment& operator=(const CAlignment& other);
46 double FindStringEditDistance();
47 CParse CalculateDisplay();
48 CParse SpellOut();
49 CParse FindSubstitution();
50 CParse FindContext();
52 void SetScore(float s) { m_Score = s; }
54 // true if the char is aligned and identical to its matchee
55 bool String1CharMatches(int);
56 bool String2CharMatches(int);
57 // true if these two chars are identical and aligned
58 bool PerfectMatch(int n, int m);
60 // which piece corresponds to piece n, if any (otherwise, 0)
61 // corresponding pieces need not be identical stringwise
62 int Str2MatchForStr1Piece(int n);
63 // which piece corresponds to piece n, if any (else 0);
64 // corresponding pieces need not be identical stringwise
65 int Str1MatchForStr2Piece(int n);
68 #endif // ALIGNMENT_H