Changeset 33579


Ignore:
Timestamp:
2019-10-17T21:05:21+13:00 (5 years ago)
Author:
ak19
Message:

Debugging. Solved one problem.

Location:
gs3-extensions/maori-lang-detection/src/org/greenstone/atea
Files:
2 edited

Legend:

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

    r33578 r33579  
    3636 * TO COMPILE:
    3737 *    maori-lang-detection/src$
    38  *       javac -cp ".:../conf:../lib/*:$OPENNLP_HOME/lib/*" org/greenstone/atea/NutchTextDumpProcessor.java
     38 *       javac -cp ".:../conf:../lib/*:$OPENNLP_HOME/lib/opennlp-tools-1.9.1.jar" org/greenstone/atea/NutchTextDumpProcessor.java
    3939 *
    4040 * TO RUN:
    4141 *    maori-lang-detection/src$
    42  *       java -cp ".:../conf:../lib/*:$OPENNLP_HOME/lib/opennlp-tools-1.9.1.jar" org/greenstone/atea/NutchTextDumpProcessor
     42 *       java -cp ".:../conf:../lib/*:$OPENNLP_HOME/lib/opennlp-tools-1.9.1.jar" org/greenstone/atea/NutchTextDumpProcessor ../crawled
    4343 *
    4444*/
     
    6767         ) {
    6868
     69        boolean readingText = false;
     70       
    6971        while((line = reader.readLine()) != null) { // readLine removes newline separator
    7072        line = line.trim();
    71         // an empty line marks the end of a page in nutch's text dump of a site
    72         if(!line.equals("")) {
     73        // iff outside of a page's body text, then an empty line marks the end of a page
     74        // in nutch's text dump of a site.
     75        // But note, there can be an empty line (or more?) between the start and end
     76        // markers of a page's text, though.
     77
     78        if(!readingText && line.equals("")) {
    7379            pageDump.append(line);
    7480            pageDump.append("\n");
    75         } else {
     81
     82           
     83            // START DEBUG
     84            debug("__________________________________________");
     85            debug("@@@ Found page entry: ");
     86            debug("__________________________________________");
     87            debug(pageDump.toString());
     88            debug("------------------------------------------");
     89            // END DEBUG
     90           
     91           
    7692            TextDumpPage page = new TextDumpPage(siteID, pageDump.toString());
    7793            // parses the fields and body text of a webpage in nutch's txt dump of entire site
     
    8096            pages.add(page);
    8197            pageDump = null;
     98           
    8299            pageDump = new StringBuilder();
    83100        }
     101        else if (!line.equals("")) { // empty line
     102            if(line.equals(TextDumpPage.TEXT_START_MARKER)) {
     103            readingText = true;
     104            }
     105            if(line.equals(TextDumpPage.TEXT_END_MARKER)) {
     106            readingText = false;
     107            }
     108            pageDump.append(line);
     109            pageDump.append("\n");
     110        }
     111        // can throw away any newlines between text start and end markers.
    84112        }
    85113       
     
    171199        else {
    172200            String siteID = siteDir.getName();
    173             NutchTextDumpProcessor nutchTxtDump = new NutchTextDumpProcessor(mriTxtDetector, siteID, txtDumpFile);
    174            
     201            debug("Found siteID: " + siteID);           
     202            NutchTextDumpProcessor nutchTxtDump = new NutchTextDumpProcessor(mriTxtDetector, siteID, txtDumpFile);         
    175203        }
    176204       
  • gs3-extensions/maori-lang-detection/src/org/greenstone/atea/TextDumpPage.java

    r33578 r33579  
    2727        // first line always has a "key:" somewhere after the pageURL
    2828        int endIndex = line.indexOf("key:");
    29         String pageURL = line.substring(endIndex);
     29
     30        //String pageURL = line.substring(0, endIndex);
     31        String pageURL = (endIndex == -1) ? line : line.substring(0, endIndex);     
     32       
    3033       
    3134        tuples.put("pageURL", pageURL.trim());
    3235
    33         String key = line.substring(endIndex);
    34         tuples.put("key", key.trim());
     36        if(endIndex != -1) {
     37        String key = line.substring(endIndex);
     38        tuples.put("key", key.trim());
     39        } else {
     40        debug("@@@@ no key for pageURL: " + pageURL);
     41        }
     42
     43        if(pageURL.contains(TEXT_END_MARKER)) {
     44        debug("@@@@ TEXT_END_MARKER assigned to pageURL for page: ");
     45        debug("+++++++++");
     46        debug(unparsedPageDump);
     47        debug("+++++++++");
     48        }
    3549
    3650        boolean readingPageText = false;
     
    7791        tuples.put("pageText", "");
    7892        }
     93
    7994       
    8095    } catch (IOException ioe) {
    8196        error("@@@@@@@@@ Error reading in txtdump of a page.", ioe);
    8297    }
     98
     99    /*
     100    // START DEBUG
     101    debug("__________________________________________");
     102    for(Map.Entry<String, String> entry : tuples.entrySet()) {
     103        String key = entry.getKey();
     104        String value = entry.getValue();       
     105        debug(key + " - " + value);
     106    }
     107    debug("__________________________________________");
     108    // END DEBUG
     109    */
    83110    }
    84111
Note: See TracChangeset for help on using the changeset viewer.