给定一个包含大量URL的列表,将这些URL按模式或正则表达式分组的最佳数据挖掘方法是什么?

我有一百万个URL的列表,我想将相似的URL聚类在一起。处理的输出将是一系列正则表达式或模式。理想情况下,我希望使用Ruby来提取数据。我最初的想法是使用机器学习分类器,但我不知道从哪里开始,也不知道使用哪种数据挖掘技术。

可能的示例:

输入:

http://www.example.com/folder-A/file.htmlhttp://www.example.com/folder-A/dude.htmlhttp://www.example.com/folder-B/huh.htmlhttp://www.example.com/folder-C/what-ever.html

输出:

http://www\.example\.com/folder-A/[a-z]\.htmlhttp://www\.example\.com/folder-[A-C]/[-a-z]\.html

回答:

这个程序:

#!/usr/bin/env perluse strict;use warnings;# the following is a CPAN module requiring independent installation:use Regexp::Assemble;my @url_list = qw(    http://www.example.com/folder-A/file.html    http://www.example.com/folder-A/dude.html    http://www.example.com/folder-B/huh.html    http://www.example.com/folder-C/what-ever.html);my $asm = Regexp::Assemble->new;for my $url (@url_list) {    $asm->add($url);}my $pat = $asm->re;for ($pat) {    s/^.*?://;    s/\)$//;}print "$pat\n";

运行后,正确输出了:

http://www.example.com/folder-(?:A/(?:dud|fil)e|C/what-ever|B/huh).html

这是您想要的结果吗?

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注