<commit_before>#include "BracketedDelegate.hh"
#include "FilterModel.hh"
#include "XSLTransformer.hh"

BracketedDelegate::BracketedDelegate(CorpusReaderPtr corpus, QWidget *parent)
:
    QStyledItemDelegate(parent),
    d_corpus(corpus),
    d_stylesheet(":/stylesheets/bracketed-sentence.xsl"),
    d_transformer(d_stylesheet)
{ }

QList<BracketedDelegate::Chunk> BracketedDelegate::parseChunks(QModelIndex const &index) const
{
    QString filename(index.data(Qt::UserRole).toString());
    
    if (!d_cache.contains(filename))
    {
        FilterModel const *model = dynamic_cast<FilterModel const *>(index.model());
        
        QString bracketed_sentence(transformXML(
            d_corpus->read(filename),
            model != 0 ? model->lastQuery() : ""
        ));
        
        QList<Chunk> *chunks = parseSentence(bracketed_sentence);
        
        d_cache.insert(filename, chunks);
    }<commit_msg>Fixed alignment in the BracketedColorDelegate<commit_after>#include "BracketedDelegate.hh"
#include "FilterModel.hh"
#include "XSLTransformer.hh"

BracketedDelegate::BracketedDelegate(CorpusReaderPtr corpus, QWidget *parent)
:
    QStyledItemDelegate(parent),
    d_corpus(corpus),
    d_stylesheet(":/stylesheets/bracketed-sentence.xsl"),
    d_transformer(d_stylesheet)
{ }

QList<BracketedDelegate::Chunk> BracketedDelegate::parseChunks(QModelIndex const &index) const
{
    QString filename(index.data(Qt::UserRole).toString());
    
    if (!d_cache.contains(filename))
    {
        FilterModel const *model = dynamic_cast<FilterModel const *>(index.model());
        
        QString bracketed_sentence(transformXML(
            d_corpus->read(filename),
            model != 0 ? model->lastQuery() : ""
        ).trimmed());
        
        QList<Chunk> *chunks = parseSentence(bracketed_sentence);
        
        d_cache.insert(filename, chunks);
    }
{'fraction_non_alphanumeric': 0.1224814422057264, 'fraction_numerical': 0.0010604453870625664, 'mean_word_length': 3.741206030150754, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5926841', 'n_tokens_mistral': 592, 'n_tokens_neox': 572, 'n_words': 85}