<commit_before>package uk.ac.ebi.biostudies.utils.saxon.search;

/**
 * Created by ehsan on 24/11/2016.
 */
import org.apache.lucene.analysis.core.SimpleAnalyzer;
import org.apache.lucene.facet.*;
import  org.apache.lucene.facet.taxonomy.*;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



import java.io.File;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class FacetManager {

    private final static Logger logger = LoggerFactory.getLogger(FacetManager.class);

    public static String[] COMPOUNDS = {"idarubicin","doxorubicin", "dmso (0.1%)", "epirubicin", "untreated", "daunorubicin", "idarubicin"
    ,"dmso", "dmso (fluctuating)"};
    public static Map<String, String> ALL_COMPOUNDS = new HashMap<>();
    private static TaxonomyWriter TAXONOMY_WRITER;
    public final static FacetsConfig FACET_CONFIG = new FacetsConfig();
    private static TaxonomyReader TAXO_READER;
    public static String TAXO_PATH = null;
    private static String FACET_RESULTS;
    private static Map <String, String> AllDims = new HashMap<>();
    public static synchronized void init(){
        FACET_CONFIG.setMultiValued("compound", true);
        for(String cmp:COMPOUNDS){
            ALL_COMPOUNDS.put(cmp, cmp);
        }
        Directory taxoDirectory = null;
        try {
            taxoDirectory = FSDirectory.open(new File(TAXO_PATH).toPath());
            TAXONOMY_WRITER = new DirectoryTaxonomyWriter(taxoDirectory, IndexWriterConfig.OpenMode.CREATE);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static synchronized TaxonomyWriter getTaxonomyWriter(){
        if(TAXONOMY_WRITER==null)
            init();
        return TAXONOMY_WRITER;

    }<commit_msg>Adding new compound facet fluorouracil<commit_after>package uk.ac.ebi.biostudies.utils.saxon.search;

/**
 * Created by ehsan on 24/11/2016.
 */
import org.apache.lucene.analysis.core.SimpleAnalyzer;
import org.apache.lucene.facet.*;
import  org.apache.lucene.facet.taxonomy.*;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



import java.io.File;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class FacetManager {

    private final static Logger logger = LoggerFactory.getLogger(FacetManager.class);

    public static String[] COMPOUNDS = {"idarubicin","doxorubicin", "dmso (0.1%)", "epirubicin", "untreated", "daunorubicin", "idarubicin"
    ,"dmso", "dmso (fluctuating)", "fluorouracil", "phenytoin", "rifampicin", "diclofenac", "mitoxantrone", "docetaxel", "azathioprine", "acetaminophen"};
    public static Map<String, String> ALL_COMPOUNDS = new HashMap<>();
    private static TaxonomyWriter TAXONOMY_WRITER;
    public final static FacetsConfig FACET_CONFIG = new FacetsConfig();
    private static TaxonomyReader TAXO_READER;
    public static String TAXO_PATH = null;
    private static String FACET_RESULTS;
    private static Map <String, String> AllDims = new HashMap<>();
    public static synchronized void init(){
        FACET_CONFIG.setMultiValued("compound", true);
        for(String cmp:COMPOUNDS){
            ALL_COMPOUNDS.put(cmp, cmp);
        }
        Directory taxoDirectory = null;
        try {
            taxoDirectory = FSDirectory.open(new File(TAXO_PATH).toPath());
            TAXONOMY_WRITER = new DirectoryTaxonomyWriter(taxoDirectory, IndexWriterConfig.OpenMode.CREATE);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static synchronized TaxonomyWriter getTaxonomyWriter(){
        if(TAXONOMY_WRITER==null)
            init();
        return TAXONOMY_WRITER;

    }
{'fraction_non_alphanumeric': 0.10940919037199125, 'fraction_numerical': 0.00525164113785558, 'mean_word_length': 4.039691289966924, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2502243', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1416, 'n_words': 296}