背景
将数据库列名称拆分为等效的英文文本以作为数据字典的种子。英语词典是根据公司文档、wiki 和电子邮件的语料库创建的。字典 ( lexicon.csv
) 是一个包含单词和概率的 CSV 文件。因此,某人写“治疗师”一词的频率越高(在电子邮件或维基页面上),“治疗师姓名”分裂为“治疗师姓名”而不是其他内容的机会就越高。(词典可能甚至不包括强奸犯这个词。)
源代码
- TextSegmenter.java @ http://pastebin.com/taXyE03L
- SortableValueMap.java @ http://pastebin.com/v3hRXYan
数据文件
- lexicon.csv - http://pastebin.com/0crECtXY
- columns.txt - http://pastebin.com/EtN9Qesr
问题(2011-01-03 更新)
当遇到以下问题时:
dependentrelationship::end depend ent dependent relationship
end=0.86
ent=0.001
dependent=0.8
relationship=0.9
存在这些可能的解决方案:
dependentrelationship::dependent relationship
dependentrelationship::dep end ent relationship
dependentrelationship::depend ent relationship
词典包含具有相对概率(基于词频)的词: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;
您将如何实现一个基于词典覆盖率和概率生成最可能解决方案的例程?例如:
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() );
}
谢谢!