现在有一个标注好chunk的文本句子,如下所示:
Some circuit breakers #### installed ####the October 1987 crash ####failed ####their first test ####unable ####to cool ####the selling panic ####both stocks and futures现在对每一个chunk例如第一个Some circuit breakers,要去几十个G的大规模语料中搜搜包含该chunk的句子(该语料已被切分成一个个独立的句子),需要进行模糊匹配,即搜索到的句子可以包含完整的chunk,也可以只包含chunk的一部分(但至少要大于两个单词),如“Some circuit”或者“circuit breakers”,如果语料中的句子包含这样的情况也符合要求。语料样例:
1_1,Two American heavyweights ininternational sport, one who weighs 286 pounds and the other 89,found something in common Sunday at the Goodwill Games.Both lost bids for gold medals.
1_2,Both were beaten by Russianopponents.Wrestler Bruce Baumgartner, the heaviest member of the U.S.contingent here, was outpointed in overtime by Andrei Shumilin.Gymnast Shannon Miller, one of the smallest Americans, had tosettle for a rare silver in the women's all-around competitionbehind Russian pixie Dina Kochetkova.Those setbacks for two U.S. athletes who rarely lose, and havedominated their individual events on the world scene, cast a cloudover Sunday's Goodwill competition for American followers.The setting for the dual disaster was the same.
1_3,Sweltering SKKStadium resembled a steamroom late into the night aftertemperatures again climbed into the high 80s by mid-afternoon.Miller, the most decorated American gymnast ever, hadn't lost inmore than two years.

现在遇到的问题:
1.如何实现这样的模糊查询
2.语料特别大,如何进行快速的搜索。希望各位大神帮忙看一下!万分感谢!
自然语言处理检索java模糊检索搜索

解决方案 »

  1.   

    首先对所有语料建立全文索引,单位是每两个单词。比如Two American heavyweights ininternational sport这一段,包含了Key:{Two American|American heavyweights|heavyweights ininternational|ininternational sport}。你要建立一个index,里面的Key就是这种两个词两个词的,每个词指向一个语料集合,比如1_4也含有Two American,那么在1_4和1_1都包含在Two American这个key所指向的集合。这个Index就是一个有序数组(B+Tree结构),存在文件和内存里。然后你把chunk也拆成两个两个单词,在index中寻找即可。另一个思路是对语料用一个单词建立index,在chunk中也对每一个单词找到一个集合,然后先后取交集。第一种index中Key较多,第二种多了一个找集合交集的操作,各有优缺点。