Dav*_*vis 5 java nlp data-dictionary text-segmentation
将数据库列名拆分为等效的英文文本以生成数据字典.英语词典是从公司文档,维基和电子邮件的语料库中创建的.dictionary(lexicon.csv
)是一个包含单词和概率的CSV文件.因此,有人写"治疗师"这个词(在电子邮件或维基页面上)的次数越多,"治疗师名称"分裂为"治疗师名称"的可能性就越大,而不是其他东西.(词典可能甚至不包括强奸犯这个词.)
遇到以下问题时:
dependentrelationship::end depend ent dependent relationship
end=0.86
ent=0.001
dependent=0.8
relationship=0.9
Run Code Online (Sandbox Code Playgroud)
存在以下可能的解决方
dependentrelationship::dependent relationship
dependentrelationship::dep end ent relationship
dependentrelationship::depend ent relationship
Run Code Online (Sandbox Code Playgroud)
词典包含与它们的相对概率的话(基于字频): ,dependent 0.8
,end 0.86
,relationship 0.9
,depend 0.3
和ent 0.001
.
消除dep end ent relationship
因为dep
不在词典中的解决方案(即75%的单词使用),而其他两个解决方案覆盖了词典中100%的单词.在剩余的解决方案中,概率dependent relationship
为0.72,而depend ent relationship
为0.00027.因此,我们可以选择dependent relationship
正确的解决方案.
鉴于:
// The concatenated phrase or database column (e.g., dependentrelationship).
String concat;
// All words (String) in the lexicon within concat, in left-to-right order; and
// the ranked probability of those words (Double). (E.g., {end, 0.97}
// {dependent, 0.86}, {relationship, 0.95}.)
Map.Entry<String, Double> word;
Run Code Online (Sandbox Code Playgroud)
您将如何实现基于词典覆盖率和概率生成最可能解决方案的例程?例如:
for( Map.Entry<String, Double> word : words ) {
result.append( word.getKey() ).append( ' ' );
// What goes here?
System.out.printf( "%s=%f\n", word.getKey(), word.getValue() );
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
我会稍微不同地处理这个问题。重要的是“结束”和“依赖”重叠,但这在你的“地图”一词中丢失了。如果您要创建一组单词映射,而不是单个单词映射,其中每个单词映射代表列名称的可能分段,仅包含不重叠的单词,则您可以根据单词的概率计算每个分段的分数和字长。分段的分数将是分段中各个单词的分数的平均值。单个单词的分数将是单词长度(l)和概率(p)的函数,类似于
得分=al+bp其中 a 和 b 是权重,您可以调整它们以获得正确的混合。对每个单词的分数进行平均以获得分词的分数,并选择分数最高的分词。得分函数也不必是线性加权,您可以尝试使用对数、指数或高阶多项式(例如平方)
归档时间: |
|
查看次数: |
6970 次 |
最近记录: |