Ignore:
Timestamp:
2019-10-17T23:12:38+13:00 (5 years ago)
Author:
ak19
Message:

NutchTextDumpProcessor prints each crawled site's stats: number of webpages per crawled site and how many of those were detected by OpenNLP as being in Maori (mri). Needed to make a reusable method in CCWETProcessor as public and static.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/maori-lang-detection/src/org/greenstone/atea/TextDumpPage.java

    r33580 r33582  
    7777            }
    7878            else { // dealing with the rest of the page dump's metadata
     79            // QTODO: nutch's text dump output is problematic
     80            // strange characters are in the stream and end up here
     81            // and can't detect end of metadata or even end of line.
    7982            endIndex = line.indexOf(":");
    8083            if(endIndex != -1) {
     
    8386                tuples.put(k.trim(), v.trim());
    8487            } else {
    85                 error("No meta key for meta: " + line);
     88                if(NutchTextDumpProcessor.DEBUG_MODE) {
     89                error("No meta key for meta: " + line);
     90                error(unparsedPageDump);
     91                }
    8692            }
    8793            }
     
    102108   
    103109    // START DEBUG
    104     debug("__________________________________________");
    105     for(Map.Entry<String, String> entry : tuples.entrySet()) {
    106         String key = entry.getKey();
    107         String value = entry.getValue();       
    108         debug(key + " - " + value);
    109     }
    110     debug("__________________________________________");
     110    debugTuples();
    111111    // END DEBUG
    112112   
    113113    }
    114114
     115    public void debugTuples() {
     116    if(NutchTextDumpProcessor.DEBUG_MODE) {
     117        debug("__________________________________________");
     118        for(Map.Entry<String, String> entry : tuples.entrySet()) {
     119        String key = entry.getKey();
     120        String value = entry.getValue();       
     121        debug(key + " - " + value);
     122        }
     123        debug("__________________________________________");
     124    }
     125    }
     126   
    115127   
    116128    public String getPageURL() {
    117     return tuples.get("url");
     129    return tuples.get("pageURL");
    118130    }
    119131
     
    126138    }
    127139
     140    public void add(String key, String value) {
     141    tuples.put(key, value);
     142    }
     143
     144    public void addMRILanguageStatus(boolean status) {
     145    if(status) {
     146        tuples.put("isMRI", "true");
     147    } else {
     148        tuples.put("isMRI", "false");
     149    }
     150    }
     151
     152    public boolean getMRILanguageStatus() {
     153    String value = tuples.get("isMRI");
     154    if(value == null) {
     155        return false;
     156    }
     157    if(value.equals("true")) {
     158        return true;
     159    }
     160    else {
     161        return false;
     162    }
     163
     164    }
     165   
    128166    // --------------- STATIC METHODS AND INNER CLASSED USED BY MAIN -------------- //
    129167    public static void info(String msg) {
Note: See TracChangeset for help on using the changeset viewer.