将域名拆分为组成词(如果可能)?

发布于 2024-09-11 16:25:09 字数 129 浏览 3 评论 0原文

我想将域名分解为组成词和数字,例如

iamadomain11.com = ['i', 'am', 'a', 'domain', '11']

我该怎么做?我知道可能有多种可能,但是,我目前还可以,只得到一组可能性。

I want to break a domain name into constituent words and numbers e.g.

iamadomain11.com = ['i', 'am', 'a', 'domain', '11']

How do i do this? I am aware that there may be multiple sets possible, however, i am currently even ok, just getting 1 set of possibilities.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

神也荒唐 2024-09-18 16:25:09

这个问题实际上在 O'Reilly Media 的书中得到了解决,Beautiful Data 。在第 14 章“自然语言语料库数据”中,他使用一个巨大的免费令牌频率数据集创建了一个拆分器,可以完全按照您在 Python 中想要的方式执行操作。

This is actually solved in the O'Reilly Media book, Beautiful Data. In chapter 14, "Natural Language Corpus Data", he creates a splitter to do exactly as you want in Python using a giant freely available token frequency data set.

洒一地阳光 2024-09-18 16:25:09

这是一个有趣的问题!首先你需要一本字典。出于性能原因,将其存储在哈希集中(可能可以使用Python中的字典类型)。然后,您可以迭代每个可能的字符串(“i”、“ia”、“iam”、...“n11”、“1”、“11”、“1”)并检查字典中的匹配项。然后就是迭代这些匹配,直到获得一个没有重叠的连续集。

这将是一个快速而肮脏的过程。可能有更快的方法来做到这一点。

This is a fun problem! First you would need a dictionary. For performance reasons, store this in an hashset (probably can use the dictionary type in python). You could then iterate over each possible string, ("i", "ia", "iam",..."n11", "1", "11", "1") and check for matches in the dictionary. Then it's a matter of iterating over these matches until you have a contiguous set with no overlaps.

This would be a quick and dirty. There are probably faster ways to do this.

决绝 2024-09-18 16:25:09

这听起来类似于中文标记化的问题,其中单词之间没有空格。本段摘自 Manning、Raghavan 等人所著的“信息检索简介”。 Schütze,可在此处在线获取:

这种现象达到了极限情况
与主要东亚语言(例如,
中文、日文、韩文和泰文)、
文本是在没有任何内容的情况下编写的
单词之间的空格。 [...]一种方法
这里是进行分词
作为先前的语言处理。
分词的方法多种多样
拥有大量词汇并采取
与某些最长的词汇匹配
未知单词的启发式
使用机器学习序列
模型,例如隐马尔可夫模型
或经过训练的条件随机场
超过手工切词

我建议第一步使用贪婪字典匹配,然后添加启发式方法来处理最常见的失败情况。

This sounds similar to the problem of tokenising Chinese, where there are no spaces in between words. This paragraph is taken from 'Introduction to Information Retrieval' by Manning, Raghavan & Schütze, available online here:

This phenomenon reaches its limit case
with major East Asian Languages (e.g.,
Chinese, Japanese, Korean, and Thai),
where text is written without any
spaces between words. [...] One approach
here is to perform word segmentation
as prior linguistic processing.
Methods of word segmentation vary from
having a large vocabulary and taking
the longest vocabulary match with some
heuristics for unknown words to the
use of machine learning sequence
models, such as hidden Markov models
or conditional random fields, trained
over hand-segmented words

I would suggest greedy dictionary matching as a first step, then adding heuristics to handle the most common failure cases.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文