在 PIG 中使用 TOKENIZE
我正在尝试将 PIG 中的 TOKENIZE 函数与逗号分隔的文档一起使用。我想在逗号上分割,但不要在空格上分割。例如我想要一个列表 (汽车、玩具车、兔子)是((汽车)、(玩具车)、(兔子)而不是((汽车)、(玩具)、(汽车)、(兔子))。 有办法吗?
I am trying to use the TOKENIZE function in PIG with a document that is comma separated. I would like to split on the commas, but NOT on white space. For example I would like for a list of
(car, toy car, bunny) to be ((car), (toy car), (bunny) not ((car), (toy), (car), (bunny)).
Is there a way to this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否看过 STRSPLIT 仅在逗号上进行拆分?
(它适用于 CHARARRAY,如 TOKENIZE)
Have you had a look to STRSPLIT for splitting just on the comma?
(it works for CHARARRAY like TOKENIZE)
另一种方法,
您也可以尝试使用 Flatten 运算
符示例:
输入 -> (a,(b,c))
B = foreach A 生成 $0 ,展平 ($1)
输出 -> (a,b,c)
同时使用 Flatten 和 tokenize
您可以阅读字数统计问题 这里
Alternative way,
You can try with Flatten operator as well
Example:
Input -> (a,(b,c))
B = foreach A generate $0 , flatten ($1)
Output -> (a,b,c)
Use of Flatten and tokenize together
You can read the word count problem Here