@@ -74,23 +74,30 @@ print(f"Overall Score: {result.overall_metrics['overall']:.4f}")
7474{
7575 "track_id" : " 0b7f2636-d35f-40bf-9b7f-94be4bcbb396" ,
7676 "html" : " <html><body><h1 cc-select=\" true\" >这是标题</h1></body></html>" , # 人工标注带cc-select="true" 属性
77- "groundtruth_content" : " # 标题\n\n 正文内容" ,
78- "groundtruth_content_list" : [
79- {"type" : " heading" , "content" : " 标题" , "level" : 1 },
80- {"type" : " paragraph" , "content" : " 正文内容" }
81- ],
8277 "url" : " https://orderyourbooks.com/product-category/college-books-p-u/?products-per-page=all" ,
83- "layout_id" : " orderyourbooks.com_4" ,
84- "max_layer_n" : 10 ,
85- "url_host_name" : " orderyourbooks.com" ,
86- "raw_warc_path" : " s3://cc-raw-huawei/crawl-data/CC-MAIN-2025-13/segments/1742004433093.21/warc/CC-MAIN-20250319080618-20250319110618-00909.warc.gz?bytes=461610805,172252" ,
87- "language" : " en" ,
88- "__dom_depth" : 19 ,
89- "__dom_width" : 10231 ,
90- "__type" : " __max_depth" ,
91- "__tag" : " DOM_WIDTH" ,
92- "marked_type" : " unwanted" , # normal:正常标注的网页;unable:正文内容无法抉择;unwanted:无需标注的网页;
93- "unwanted_reason" : " list"
78+ "main_html" : " <h1 cc-select=\" true\" >这是标题</h1>" , # 从html中剪枝得到的正文html
79+ "convert_main_content" : " # 这是标题" , # 从main_html+html2text转化来
80+ "groundtruth_content" : " # 这是标题" , # 人工校准的markdown(部分提供)
81+ "meta" : {
82+ "language" : " en" , # 网页的语言
83+ "style" : " artical" , # 网页的文体
84+ "DOM_WIDTH" : 176 ,
85+ "DOM_DEPTH" : 27 ,
86+ "text_linktext_ratio" : 0.12252270850536746 ,
87+ "table_text_ratio" : 0 ,
88+ "table_dom_depth" : -1 ,
89+ "text_distribution_dispersion" : 0.2663 ,
90+ "table" : [], # [], ["layout"], ["data"], ["layout", "data"]
91+ "equation" : [], # [], ["inline"], ["interline"], ["inline", "interline"]
92+ "code" : [], # [], ["inline"], ["interline"], ["inline", "interline"]
93+ "table_complexity_score" : 0 ,
94+ "dom_complexity_score" : 0.8442 ,
95+ "text_dispersion_score" : 0.2663 ,
96+ "content_diversity_score" : 0 ,
97+ "link_complexity_score" : 0.1225 ,
98+ "overall_complexity_score" : 0.3083 ,
99+ "level" : " mid" # simple, mid, hard
100+ }
94101}
95102```
96103
@@ -197,6 +204,95 @@ class MyExtractor(BaseExtractor):
197204ExtractorFactory.register(" my-extractor" , MyExtractor)
198205```
199206
207+ ### 数据集统计分析工具
208+
209+ WebMainBench 提供了强大的数据集统计分析工具 ` scripts/statics.py ` ,用于分析数据集的各种特征并自动生成复杂度评分和难易程度分类。
210+
211+ #### 功能特性
212+
213+ - ** DOM结构分析** :计算网页DOM树的深度和宽度
214+ - ** 文本链接比例分析** :统计文本与链接的比例关系
215+ - ** 表格复杂度分析** :评估表格内容的复杂程度
216+ - ** 内容类型检测** :自动识别公式、代码、表格等特殊内容
217+ - ** 复杂度评分** :基于多维度指标计算综合复杂度得分
218+ - ** 动态难易程度分类** :基于数据分布自动分类为 simple/mid/hard
219+
220+ #### 使用方法
221+
222+ ``` bash
223+ # 基本用法
224+ python scripts/statics.py data/input.jsonl --output data/output_with_stats.jsonl
225+
226+ # 使用默认数据集
227+ python scripts/statics.py
228+ ```
229+
230+ #### 参数说明
231+
232+ ``` bash
233+ # 查看所有可用参数
234+ python scripts/statics.py --help
235+
236+ ```
237+
238+ #### 输出结果
239+
240+ 工具会在每条数据的 ` meta ` 字段中添加以下统计信息:
241+
242+ ``` json
243+ {
244+ "meta" : {
245+ "DOM_DEPTH" : 25 , // DOM树深度
246+ "DOM_WIDTH" : 1200 , // DOM树宽度
247+ "text_linktext_ratio" : 0.85 , // 文本链接比例
248+ "table_complexity_score" : 0.3 , // 表格复杂度得分
249+ "dom_complexity_score" : 0.6 , // DOM复杂度得分
250+ "text_dispersion_score" : 0.4 , // 文本分布得分
251+ "content_diversity_score" : 0.7 , // 内容多样性得分
252+ "link_complexity_score" : 0.5 , // 链接复杂度得分
253+ "overall_complexity_score" : 0.52 , // 综合复杂度得分
254+ "level" : " mid" // 难易程度 (simple/mid/hard)
255+ }
256+ }
257+ ```
258+
259+ #### 复杂度评分算法
260+
261+ 综合复杂度得分由以下维度加权计算:
262+
263+ - ** DOM结构复杂度 (25%)** :基于DOM深度和宽度,使用动态归一化
264+ - ** 文本分布复杂度 (25%)** :基于文本在DOM中的分布离散程度
265+ - ** 内容多样性 (25%)** :基于公式、代码、表格等特殊内容的种类
266+ - ** 链接复杂度 (25%)** :基于文本与链接的比例关系
267+
268+ #### 运行示例
269+
270+ ``` bash
271+ # 分析数据集并生成统计报告
272+ python scripts/statics.py data/sample_dataset.jsonl --output data/analyzed_dataset.jsonl
273+
274+ # 输出示例:
275+ 🔄 第一阶段: 计算基础统计和复杂度得分...
276+ 📊 已处理 100 条数据...
277+ 📊 已处理 200 条数据...
278+
279+ 🔄 第二阶段: 计算动态阈值和难易程度分类...
280+ 📊 复杂度分布阈值计算:
281+ 总样本数: 1,827
282+ 30%分位数 (simple/mid分界): 0.3245
283+ 70%分位数 (mid/hard分界): 0.6789
284+ 复杂度得分范围: 0.0944 - 1.0000
285+
286+ 📊 难易程度分类结果:
287+ Simple: 548 (30.0%)
288+ Mid: 731 (40.0%)
289+ Hard: 548 (30.0%)
290+
291+ 📝 正在写入数据到: data/analyzed_dataset.jsonl
292+ ✅ 成功写入 1,827 条数据
293+ ```
294+
295+
200296## 项目架构
201297
202298```
0 commit comments