/***************************************************************************
 *   Copyright (C) 2004-2009 by Pere Constans
 *   constans@molspaces.com
 *   cb2Bib version 1.3.2. Licensed under the GNU GPL version 3.
 *   See the LICENSE file that comes with this distribution.
 *
 *   Class implementation of the approximate search algorithm
 *   P. Constans. Approximate textual retrieval. arXiv:0705.0751v1, 2007.
 ***************************************************************************/
#ifndef APPROXIMATEPATTERN_H
#define APPROXIMATEPATTERN_H

#include "compositePattern.h"


class approximatePattern : public compositePattern
{

public:
    approximatePattern(const QString newPattern, Qt::CaseSensitivity newCs);
    ~approximatePattern();


private:
    QList<int> ppEnds;
    QList<int> ppStarts;
    QString wordPattern(const QString& word, Qt::CaseSensitivity cs) const;
    QStringList patternPieces;
    QStringList pre;
    QStringList suf;
    const QStringList splitWord(const QString& word);
    int stretch(int piece_i, int piece_j) const;
    int wordCount(const QString& str) const;
    void setPattern();
    void splitPattern();
    void splitPattern(const QString& p, QStringList* w, QList<int>* ws, QList<int>* we) const;

};

#endif
