Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: java/org/chromium/distiller/DomDistiller.java

Issue 1131853006: Fix word count issue for Chinese and Japanese (Closed) Base URL: git@github.com:chromium/dom-distiller.git@master
Patch Set: speed up Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.distiller; 5 package org.chromium.distiller;
6 6
7 import org.chromium.distiller.proto.DomDistillerProtos; 7 import org.chromium.distiller.proto.DomDistillerProtos;
8 import org.chromium.distiller.proto.DomDistillerProtos.DebugInfo; 8 import org.chromium.distiller.proto.DomDistillerProtos.DebugInfo;
9 import org.chromium.distiller.proto.DomDistillerProtos.TimingInfo; 9 import org.chromium.distiller.proto.DomDistillerProtos.TimingInfo;
10 import org.chromium.distiller.StringUtil;
10 11
11 import com.google.gwt.core.client.js.JsExport; 12 import com.google.gwt.core.client.js.JsExport;
12 import com.google.gwt.dom.client.Document; 13 import com.google.gwt.dom.client.Document;
13 import com.google.gwt.user.client.Window; 14 import com.google.gwt.user.client.Window;
14 15
15 @JsExport("DomDistiller") 16 @JsExport("DomDistiller")
16 public class DomDistiller { 17 public class DomDistiller {
17 @JsExport 18 @JsExport
18 public static DomDistillerProtos.DomDistillerResult apply() { 19 public static DomDistillerProtos.DomDistillerResult apply() {
19 return applyWithOptions(DomDistillerProtos.DomDistillerOptions.create()) ; 20 return applyWithOptions(DomDistillerProtos.DomDistillerOptions.create()) ;
20 } 21 }
21 22
22 @JsExport 23 @JsExport
23 public static DomDistillerProtos.DomDistillerResult applyWithOptions( 24 public static DomDistillerProtos.DomDistillerResult applyWithOptions(
24 DomDistillerProtos.DomDistillerOptions options) { 25 DomDistillerProtos.DomDistillerOptions options) {
25 double startTime = DomUtil.getTime(); 26 double startTime = DomUtil.getTime();
27 StringUtil.selectCountWordsFunc(Document.get().getBody().getInnerText()) ;
cjhopman 2015/05/21 19:32:02 This should use textcontent not innertext
wychen 2015/05/21 23:07:03 Done.
26 DomDistillerProtos.DomDistillerResult result = 28 DomDistillerProtos.DomDistillerResult result =
27 DomDistillerProtos.DomDistillerResult.create(); 29 DomDistillerProtos.DomDistillerResult.create();
28 ContentExtractor contentExtractor = 30 ContentExtractor contentExtractor =
29 new ContentExtractor(Document.get().getDocumentElement()); 31 new ContentExtractor(Document.get().getDocumentElement());
30 result.setTitle(contentExtractor.extractTitle()); 32 result.setTitle(contentExtractor.extractTitle());
31 33
32 LogUtil.setDebugLevel( 34 LogUtil.setDebugLevel(
33 options.hasDebugLevel() ? options.getDebugLevel() : LogUtil.DEBU G_LEVEL_NONE); 35 options.hasDebugLevel() ? options.getDebugLevel() : LogUtil.DEBU G_LEVEL_NONE);
34 LogUtil.logToConsole("DomDistiller debug level: " + LogUtil.getDebugLeve l()); 36 LogUtil.logToConsole("DomDistiller debug level: " + LogUtil.getDebugLeve l());
35 37
(...skipping 15 matching lines...) Expand all
51 result.setMarkupInfo(contentExtractor.getMarkupParser().getMarkupInfo()) ; 53 result.setMarkupInfo(contentExtractor.getMarkupParser().getMarkupInfo()) ;
52 timingInfo.setTotalTime(DomUtil.getTime() - startTime); 54 timingInfo.setTotalTime(DomUtil.getTime() - startTime);
53 result.setTimingInfo(timingInfo); 55 result.setTimingInfo(timingInfo);
54 result.setStatisticsInfo(contentExtractor.getStatisticsInfo()); 56 result.setStatisticsInfo(contentExtractor.getStatisticsInfo());
55 DebugInfo debugInfo = DebugInfo.create(); 57 DebugInfo debugInfo = DebugInfo.create();
56 debugInfo.setLog(LogUtil.getAndClearLog()); 58 debugInfo.setLog(LogUtil.getAndClearLog());
57 result.setDebugInfo(debugInfo); 59 result.setDebugInfo(debugInfo);
58 return result; 60 return result;
59 } 61 }
60 } 62 }
OLDNEW
« no previous file with comments | « no previous file | java/org/chromium/distiller/StringUtil.java » ('j') | java/org/chromium/distiller/StringUtil.java » ('J')

Powered by Google App Engine
This is Rietveld 408576698