b**********5 发帖数: 7881 | 1 最基本的word count, 大家都知道怎么写
但如果现在是一个text document, 不但要word count, 还要output那个word的
sentence number, 我应该怎么写?
比如:
a ab c d e. ab d. e
output:
a : {1, 1} (count is 1, and appeared in the first sentence)
ab: {2, 1, 2} {count is 2, and appeared in the first/second sentence)
... |
p*****r 发帖数: 1883 | 2 把那个word的sentence number也加到key里就行了
【在 b**********5 的大作中提到】 : 最基本的word count, 大家都知道怎么写 : 但如果现在是一个text document, 不但要word count, 还要output那个word的 : sentence number, 我应该怎么写? : 比如: : a ab c d e. ab d. e : output: : a : {1, 1} (count is 1, and appeared in the first sentence) : ab: {2, 1, 2} {count is 2, and appeared in the first/second sentence) : ...
|
b**********5 发帖数: 7881 | 3 这个我知道, 但我写pig, 写不出, 那个sentence number, 你怎么得到?
【在 p*****r 的大作中提到】 : 把那个word的sentence number也加到key里就行了
|
p*****r 发帖数: 1883 | 4 每个句子的index number如果输入数据没有提供你就自己预处理加上就行
【在 b**********5 的大作中提到】 : 这个我知道, 但我写pig, 写不出, 那个sentence number, 你怎么得到?
|
b**********5 发帖数: 7881 | 5 小姐啊, 你这个pre processing, 怎么也在map reduce 里? 怎么用pig 写?
【在 p*****r 的大作中提到】 : 每个句子的index number如果输入数据没有提供你就自己预处理加上就行
|
p*****r 发帖数: 1883 | 6 https://issues.apache.org/jira/browse/PIG-2353
伸手党小姐啊,谷歌一下就知道了,pig 0.11开始有RANK function
【在 b**********5 的大作中提到】 : 小姐啊, 你这个pre processing, 怎么也在map reduce 里? 怎么用pig 写?
|
b**********5 发帖数: 7881 | 7 还是看不出怎么弄。 你写个pig script让我看看?》
【在 p*****r 的大作中提到】 : https://issues.apache.org/jira/browse/PIG-2353 : 伸手党小姐啊,谷歌一下就知道了,pig 0.11开始有RANK function
|
p*****r 发帖数: 1883 | 8 sorry no babysitting for now
【在 b**********5 的大作中提到】 : 还是看不出怎么弄。 你写个pig script让我看看?》
|
b**********5 发帖数: 7881 | 9 我怎么觉得你说的, 这些都不对。 你一开始说的, 我也知道, tuple要个sentence
number。 但真要implememnt起来, 你也不知道。。。
【在 p*****r 的大作中提到】 : sorry no babysitting for now
|
l*******m 发帖数: 1096 | 10 http://stackoverflow.com/questions/18544602/how-to-flatten-a-gr
【在 b**********5 的大作中提到】 : 这个我知道, 但我写pig, 写不出, 那个sentence number, 你怎么得到?
|
b**********5 发帖数: 7881 | 11 你这个不对。 我要generate一个sentence number, 你这个sentence number怎么
generate。
rank是对的。 rank没有field的话, 就是give u an increasing id
【在 l*******m 的大作中提到】 : http://stackoverflow.com/questions/18544602/how-to-flatten-a-gr
|
b*****n 发帖数: 618 | 12 我不会pig,这个如果用mapreduce还是可以的,因为sentence number必须要读完整个
file才知道,所以可能需要一个自己写custom inputformat,在算split的时候需要先
把整个file读一遍,每个split不仅要有offset信息还要有sentence #的起始信息,然
后每个不同的recordreader读出来的结果就可以让sentence #做key,sentence内容做
value了。
如果一开始把文件完整读一下不想单机做的话,也许可能的solution是用两个
mapreduce,第一个mapreduce先把每个split的sentence的数量算出来,然后第二个
mapreduce利用第一个的结果,比如放到distributed cache里面,然后仍然需要自己写
一个custom inputformat。。不过就是节省了第一次读完整文件的时间。
暂时就想到这么多。。 |
b*****n 发帖数: 618 | 13 其实还不如就用一个process读一下文件,边读边生成另一个文件,sentence #做key
,sentence内容做value,然后再run mapreduce,不用custom inputformat,非常简单
,就是开始多读一遍文件。
其实都复杂了,就一个mapper搞就行了。。sentence #用个local variable
如果让我做我肯定这么搞。。 |