19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_MOBILIZE_LABEL_FILTER_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_MOBILIZE_LABEL_FILTER_H_
26 #include "pagespeed/kernel/base/basictypes.h"
27 #include "pagespeed/kernel/base/string.h"
29 namespace net_instaweb {
31 class HtmlCharactersNode;
50 int content_bytes,
int content_non_blank_bytes);
55 GoogleString ToString(
bool readable, HtmlParse* parser);
84 kUseTagNamesAndClassifier = 3,
89 static const char kPagesRoleAdded[];
90 static const char kNavigationalRoles[];
91 static const char kHeaderRoles[];
92 static const char kContentRoles[];
93 static const char kMarginalRoles[];
94 static const char kDivsUnlabeled[];
95 static const char kAmbiguousRoleLabels[];
100 static void InitStats(Statistics* statistics);
102 virtual const char* Name()
const {
return "MobilizeLabel"; }
104 virtual void StartElementImpl(HtmlElement* element);
105 virtual void EndElementImpl(HtmlElement* element);
106 virtual void Characters(HtmlCharactersNode* characters);
107 virtual void EndDocument();
113 LabelingMode labeling_mode()
const {
114 return labeling_mode_;
120 void CheckAttributeStrings(HtmlElement* element);
122 ElementSample* MakeNewSample(HtmlElement* element);
123 void PopSampleStack();
124 void ComputeContained(ElementSample* sample);
125 void AggregateToTopOfStack(ElementSample* sample);
126 void IncrementRelevantTagDepth();
127 void SanityCheckEndOfDocumentState();
128 void ComputeProportionalFeatures();
132 HtmlElement* active_no_traverse_element_;
133 int relevant_tag_depth_;
134 int max_relevant_tag_depth_;
137 int content_non_blank_bytes_;
138 bool were_roles_added_;
139 LabelingMode labeling_mode_;
141 std::vector<ElementSample*> samples_;
142 std::vector<ElementSample*> sample_stack_;
144 Variable* pages_labeled_;
145 Variable* pages_role_added_;
147 Variable* divs_unlabeled_;
148 Variable* ambiguous_role_labels_;
150 DISALLOW_COPY_AND_ASSIGN(MobilizeLabelFilter);
Definition: common_filter.h:48
ElementSample * parent
NULL for global count.
Definition: mobilize_label_filter.h:58
void set_labeling_mode(LabelingMode m)
Definition: mobilize_label_filter.h:110
virtual void Characters(HtmlCharactersNode *characters)
static const char kPagesLabeled[]
Monitoring variable names.
Definition: mobilize_label_filter.h:88
Definition: mobilize_rewrite_filter.h:58
Definition: mobilize_label_filter.h:78
Definition: mobilize_label_filter.h:48
MobileRole::Level role
Mobile role (from parent where applicable)
Definition: mobilize_label_filter.h:59
Level
Definition: mobilize_rewrite_filter.h:40
Definition: rewrite_driver.h:98
void ComputeProportionalFeatures(ElementSample *normalized)
HtmlElement * element
NULL for global count.
Definition: mobilize_label_filter.h:57
std::vector< double > features
feature vector, always of size kNumFeatures.
Definition: mobilize_label_filter.h:60
virtual void StartDocumentImpl()