Accelerated-c++-置换索引

问题

第五章练习题5-1.
设计和实现一个程序以产生一个置换索引。
在一个置换索引当中,每个短语都是以这个短语的每一个单词作为索引的(类似倒排,内容做索引)。因此,假如有如下的输入:

The quick brown fox
jumped over the fence
得到如下的输出:
The quick \t brown fox
jumped over the \t fence
The quick brown \t fox
\t jumped over the fence
jumped \t over the fence
The \t quick brown fox
jumped over \t the fence
\t The quick brown fox

这个输出有一点摸不着头脑!

思路

这个题用的是书本给出的思路。
1.产生轮转集合
The quick brown fox (The是置换索引)
quick brown fox The(quick)
brown fox The quick(brown)
fox The quick brown(fox)
jumped over the fence(jumped)
over the fence jumped(over)
the fence jumped over(the)
fence jumped over the(fence)

2.排序。
对字符串进行排序,但是排序的一句是置换索引。
排序之后的结果为:
brown fox The quick(brown)
fence jumped over the(fence)
fox The quick brown(fox)
jumped over the fence(jumped)
over the fence jumped(over)
quick brown fox The(quick)
the fence jumped over(the)
The quick brown fox(The)

3.值置换索引开始输出,直到当前串的第一个单词,用\t分割
brown fox \t The quick
fence \t jumped over the
fox \t The quick brown
jumped over the fence \t
over the fence \t jumped
quick brown fox \t The
the fence \t jumped over
The quick brown fox \t

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值