Mercurial > hg > classical
comparison common/Objects.h @ 10:d35e5d769c87 classical-rdf
* some experiments with composer name matching
author | Chris Cannam |
---|---|
date | Wed, 17 Feb 2010 19:26:48 +0000 |
parents | 719a4f477098 |
children | 98047b91b09d |
comparison
equal
deleted
inserted
replaced
9:9e2b203254ab | 10:d35e5d769c87 |
---|---|
211 | 211 |
212 struct Ordering { | 212 struct Ordering { |
213 bool operator()(Work *, Work *); | 213 bool operator()(Work *, Work *); |
214 }; | 214 }; |
215 | 215 |
216 /** | |
217 * Compare the ordering of two strings that are known to contain | |
218 * catalogue number texts, such as "Op. 1 no 4" and "Op. 3 no 2" | |
219 * (which should compare in that order). Return value is as for | |
220 * strcmp. | |
221 */ | |
222 //!!! todo: unit tests | |
223 static int compareCatalogueNumberTexts(QString a, QString b); | |
224 | |
216 private: | 225 private: |
217 QString m_key; | 226 QString m_key; |
218 QString m_opus; | 227 QString m_opus; |
219 QString m_catalogue; | 228 QString m_catalogue; |
220 QString m_number; | 229 QString m_number; |
272 Q_PROPERTY(QSet<QUrl> geonameURIs READ geonameURIs WRITE setGeonameURIs STORED true) | 281 Q_PROPERTY(QSet<QUrl> geonameURIs READ geonameURIs WRITE setGeonameURIs STORED true) |
273 Q_PROPERTY(QString period READ period WRITE setPeriod STORED true) | 282 Q_PROPERTY(QString period READ period WRITE setPeriod STORED true) |
274 Q_PROPERTY(ClassicalData::Birth *birth READ birth WRITE setBirth STORED true) | 283 Q_PROPERTY(ClassicalData::Birth *birth READ birth WRITE setBirth STORED true) |
275 Q_PROPERTY(ClassicalData::Death *death READ death WRITE setDeath STORED true) | 284 Q_PROPERTY(ClassicalData::Death *death READ death WRITE setDeath STORED true) |
276 | 285 |
286 Q_PROPERTY(QString surname READ getSurname STORED false) | |
287 Q_PROPERTY(QString forenames READ getForenames STORED false) | |
288 | |
277 public: | 289 public: |
278 Composer(QObject *parent = 0) : NamedEntity(parent), m_birth(0), m_death(0) { } | 290 Composer(QObject *parent = 0) : NamedEntity(parent), m_birth(0), m_death(0) { } |
279 | 291 |
280 QString gender() const { return m_gender; } | 292 QString gender() const { return m_gender; } |
281 void setGender(QString n) { m_gender = n; } | 293 void setGender(QString n) { m_gender = n; } |
297 | 309 |
298 Death *death() { return m_death; } | 310 Death *death() { return m_death; } |
299 const Death *death() const { return m_death; } | 311 const Death *death() const { return m_death; } |
300 void setDeath(Death *d) { m_death = d; } | 312 void setDeath(Death *d) { m_death = d; } |
301 | 313 |
302 bool datesMatch(const Composer *other) const; // "well enough" | 314 QString getSurname() const; |
315 QString getForenames() const; | |
303 QString getSortName(bool caps) const; | 316 QString getSortName(bool caps) const; |
304 QString getDisplayDates() const; | 317 QString getDisplayDates() const; |
318 | |
319 /** | |
320 * Given another composer, return true if the other composer's | |
321 * dates match outs. This is mostly intended (like | |
322 * matchCatalogueName) for use in merging distinct catalogues. | |
323 * Matching is somewhat fuzzy; more slack is cut when the dates | |
324 * are very long ago or are marked as approximate. | |
325 */ | |
326 bool matchDates(const Composer *other) const; // "well enough" | |
327 | |
328 /** | |
329 * Given another name which is intended to be a well-formatted | |
330 * catalogue name for a composer (but which may differ in | |
331 * ordering, number of forenames, and perhaps in spelling), test | |
332 * whether the name is a plausible match for our own. This is | |
333 * mostly intended (like matchDates) for use in merging distinct | |
334 * catalogues. Return true if the given name is highly likely to | |
335 * match our own. | |
336 */ | |
337 bool matchCatalogueName(QString otherName) const; | |
338 | |
339 /** | |
340 * Given another name which is believed to be a user-entered | |
341 * composer name with unpredictable formatting and spelling (and | |
342 * probably incomplete), return an estimate for the likelihood | |
343 * that the intended composer was this one. Higher return values | |
344 * indicate greater confidence. | |
345 */ | |
346 int matchFuzzyName(QString name) const; | |
347 | |
348 /** | |
349 * Return the supplied name reduced into a "simplified" form, | |
350 * eliminating many of the differences often found particularly in | |
351 * European language names that have been anglicised. Used in | |
352 * catalogue and fuzzy name matching. | |
353 */ | |
354 static QString reduceName(QString name); | |
305 | 355 |
306 private: | 356 private: |
307 QString m_gender; | 357 QString m_gender; |
308 QSet<QString> m_nationality; | 358 QSet<QString> m_nationality; |
309 QSet<QUrl> m_geonameURIs; | 359 QSet<QUrl> m_geonameURIs; |