<commit_before>package org.eclipselabs.recommenders.codesearchquery.rcp;

import java.io.IOException;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.KeywordAnalyzer;
import org.apache.lucene.analysis.PerFieldAnalyzerWrapper;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Version;

public abstract class AbstractIndex {

    private Directory m_index = null;
    private Analyzer m_analyzer = null;

    private final static Version luceneVersion = Version.LUCENE_35;

    // public AbstractIndex(Directory directory, Analyzer analyzer) {
    // m_index = directory;
    // m_analyzer = analyzer;
    // }

    public AbstractIndex(final Directory directory) throws IOException {
        m_index = directory;
        // m_analyzer = new Analyzer(){
        //
        // @Override
        // public TokenStream tokenStream(String fieldName, Reader reader) {
        // //
        // //return new KeywordTokenizer(reader);
        // return new WhitespaceTokenizer(reader);
        // }
        // };
        m_analyzer = new PerFieldAnalyzerWrapper(new KeywordAnalyzer());
        ((PerFieldAnalyzerWrapper) m_analyzer).addAnalyzer(Fields.FULL_TEXT, new StandardAnalyzer(getVersion()));
    }

    public static Version getVersion() {
        return luceneVersion;
    }

    public Directory getIndex() {
        return m_index;
    }

    public Analyzer getAnalyzer() {
        return m_analyzer;
    }
}<commit_msg>Refactoring analyzer initialization<commit_after>package org.eclipselabs.recommenders.codesearchquery.rcp;

import java.io.IOException;
import java.util.Map;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.KeywordAnalyzer;
import org.apache.lucene.analysis.PerFieldAnalyzerWrapper;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Version;

import com.google.common.collect.Maps;

public abstract class AbstractIndex {

    private Directory m_index = null;
    private Analyzer m_analyzer = null;

    private final static Version luceneVersion = Version.LUCENE_35;

    // public AbstractIndex(Directory directory, Analyzer analyzer) {
    // m_index = directory;
    // m_analyzer = analyzer;
    // }

    public AbstractIndex(final Directory directory) throws IOException {
        m_index = directory;

        Map<String, Analyzer> analyzerPerField = Maps.newHashMap();
        analyzerPerField.put(Fields.FULL_TEXT, new StandardAnalyzer(getVersion()));

        m_analyzer = new PerFieldAnalyzerWrapper(new KeywordAnalyzer(), analyzerPerField);
    }

    public static Version getVersion() {
        return luceneVersion;
    }

    public Directory getIndex() {
        return m_index;
    }

    public Analyzer getAnalyzer() {
        return m_analyzer;
    }
}
{'fraction_non_alphanumeric': 0.09264957264957265, 'fraction_numerical': 0.0013675213675213675, 'mean_word_length': 3.3802395209580838, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '6006058', 'n_tokens_mistral': 866, 'n_tokens_neox': 812, 'n_words': 176}