Ignore:
Timestamp:
2016-12-20T14:15:05+13:00 (7 years ago)
Author:
davidb
Message:

Support for icu-tokenize property added, plus relevant refactoring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/hathitrust/wcsa/extracted-features-solr/trunk/solr-ingest/src/main/java/org/hathitrust/extractedfeatures/SolrDocJSON.java

    r31245 r31252  
    2424public class SolrDocJSON {
    2525
    26     protected static ArrayList<String> getTokenPosCountWords(JSONObject ef_token_pos_count, String page_id)
    27     {
    28         boolean solr_icu_tokenize = true;
     26    protected static ArrayList<String> getTokenPosCountWords(JSONObject ef_token_pos_count, String page_id,
     27                                                             boolean icu_tokenize)
     28    {
    2929       
    3030        ArrayList<String> words = new ArrayList<String>();
     
    3636                String token = token_iter.next();
    3737               
    38                 if (solr_icu_tokenize == true) {
     38                if (icu_tokenize == true) {
    3939                    Reader reader = new StringReader(token);
    4040                   
     
    7979   
    8080    protected static String generateSolrText(JSONObject ef_token_pos_count, String page_id,
    81                                             WhitelistBloomFilter whitelist_bloomfilter)
    82     {
    83         ArrayList<String> tokens = getTokenPosCountWords(ef_token_pos_count, page_id);
     81                                            WhitelistBloomFilter whitelist_bloomfilter, boolean icu_tokenize)
     82    {
     83        ArrayList<String> tokens = getTokenPosCountWords(ef_token_pos_count, page_id,icu_tokenize);
    8484
    8585        StringBuilder sb = new StringBuilder();
     
    125125
    126126    protected static JSONObject generateSolrDocJSON(String volume_id, String page_id, JSONObject ef_page,
    127                                                     WhitelistBloomFilter whitelist_bloomfilter)
     127                                                    WhitelistBloomFilter whitelist_bloomfilter, boolean icu_tokenize)
    128128    {
    129129        JSONObject solr_update_json = null;
     
    137137                    JSONObject solr_add_json = new JSONObject();
    138138   
    139                     String text = generateSolrText(ef_token_pos_count,page_id,whitelist_bloomfilter);
     139                    String text = generateSolrText(ef_token_pos_count,page_id,whitelist_bloomfilter,icu_tokenize);
    140140                   
    141141                    JSONObject solr_doc_json = new JSONObject();
     
    213213    }
    214214
    215     protected static ArrayList<String> generateTokenPosCountText(String volume_id, String page_id, JSONObject ef_page)
     215    protected static ArrayList<String> generateTokenPosCountText(String volume_id, String page_id, JSONObject ef_page,
     216                                                                 boolean icu_tokenize)
    216217    {
    217218        ArrayList<String> word_list = null;
     
    221222            if (ef_body != null) {
    222223                JSONObject ef_token_pos_count = ef_body.getJSONObject("tokenPosCount");
    223                 word_list = getTokenPosCountWords(ef_token_pos_count,page_id);
     224                word_list = getTokenPosCountWords(ef_token_pos_count,page_id,icu_tokenize);
    224225            }
    225226            else {
Note: See TracChangeset for help on using the changeset viewer.