grunt> cat /opt/dataset/input.txt
keyword1 keyword2
keyword2 keyword4
keyword3 keyword1
keyword4 keyword4
A = LOAD '/opt/dataset/input.txt' using PigStorage('\n') as (line:chararray);
B = foreach A generate TOKENIZE((chararray)$0);
C = foreach B generate flatten($0) as word;
D = group C by word;
E = foreach D generate COUNT(C), group;
dump B;
({(keyword1),(keyword2)})
({(keyword2),(keyword4)})
({(keyword3),(keyword1)})
({(keyword4),(keyword4)})
dump C;
(keyword1)
(keyword2)
(keyword2)
(keyword4)
(keyword3)
(keyword1)
(keyword4)
(keyword4)
dump D;
(keyword1,{(keyword1),(keyword1)})
(keyword2,{(keyword2),(keyword2)})
(keyword3,{(keyword3)})
(keyword4,{(keyword4),(keyword4),(keyword4)})
dump E;
(2,keyword1)
(2,keyword2)
(1,keyword3)
(3,keyword4)
store E into './wordcount';
TOKENIZE
Splits a string and outputs a bag of words. Syntax
TOKENIZE(expression) Terms
expression An expression with data type chararray. Usage
Use the TOKENIZE function to split a string of words (all words in a single tuple) into a bag of words (each word in a single tuple). The following characters are considered to be word separators: space, double quote("), coma(,) parenthesis(()), star(*). Example
In this example the strings in each row are split. A = LOAD 'data' AS (f1:chararray); DUMP A;
(Here is the first string.)
(Here is the second string.)
(Here is the third string.) X = FOREACH A GENERATE TOKENIZE(f1); DUMP X;
({(Here),(is),(the),(first),(string.)})
({(Here),(is),(the),(second),(string.)})
({(Here),(is),(the),(third),(string.)})


pig—WordCount analysis的更多相关文章

  1. WordCount Analysis

    1.Create a new java project, then copy examples folder from /home/hadoop/hadoop-1.0.4/src; Create a ...

  2. Hive Word count

    --https://github.com/slimandslam/pig-hive-wordcount/blob/master/wordcount.hql DROP TABLE myinput; DR ...

  3. Latent semantic analysis note(LSA)

    1 LSA Introduction LSA(latent semantic analysis)潜在语义分析,也被称为LSI(latent semantic index),是Scott Deerwes ...

  4. Hadoop:pig 安装及入门示例

    pig是hadoop的一个子项目,用于简化MapReduce的开发工作,可以用更人性化的脚本方式分析数据. 一.安装 a) 下载 从官网http://pig.apache.org下载最新版本(目前是0 ...

  5. hadoop家族之pig入门

    昨天成功运行第一个在hadoop集群上面的python版本的wordcount,今天白天继续看网上提供的文档.下午上头给定的回复是把hadoop家族都熟悉一下,那就恭敬不如从命,开始学习pig吧- 这 ...

  6. pig对null的处理(实际,对空文本处理为两种取值null或‘’)

    pig对文本null的处理非常特殊.会处理成两种null,还会处理成''这样的空值. 比方,读name,age,sex日志信息.name取值处理,假设记录为".,,"这样,会将na ...

  7. 软件质量与测试--第二周作业 WordCount

    github地址: https://github.com/wzfhuster/software_test_tasks psp表格: PSP2.1 PSP 阶段 预估耗时 (分钟) 实际耗时 (分钟) ...

  8. 软件质量与测试——WordCount编码实现及测试

    1.GitHub地址       https://github.com/noblegongzi/WordCount 2.PSP表格 PSP2.1 PSP 阶段 预估耗时 (分钟) 实际耗时 (分钟) ...

  9. 第二周个人作业WordCount

    1.Github地址 https://github.com/JingzheWu/WordCount 2.PSP表格 PSP2.1 PSP阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning ...

随机推荐

  1. java基础38 正则表达式

    1.常用的正则表达式  预定义字符类:.  任何字符(与行结束符可能匹配也可能不匹配) \d  数字:[0-9] \D  非数字: [^0-9] \s  空白字符:[ \t\n\x0B\f\r] \S ...

  2. 夜神模拟器调试android studio项目

    这几天为了android studio也是醉了,先是R文件丢失忙活一下午,各种百度谷歌,最后终于解决这个小问题,没想到在启动avd这个问题上更是棘手,网上的方法试了,主要有三种,上篇博文http:// ...

  3. 浮动元素垂直居中,bootstrap栅格布局垂直居中

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 区间DP小结

    也写了好几天的区间DP了,这里稍微总结一下(感觉还是不怎么会啊!). 但是多多少少也有了点感悟: 一.在有了一点思路之后,一定要先确定好dp数组的含义,不要模糊不清地就去写状态转移方程. 二.还么想好 ...

  5. HDU 2874 Connections between cities(LCA(离线、在线)求树上距离+森林)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2874 题目大意:给出n个点,m条边,q个询问,每次询问(u,v)的最短距离,若(u,v)不连通即不在同 ...

  6. SQL2008关于权限的解释

    在SQL2008中我自己创建的一个登录名,可是那个登录名只可以用来登录,对数据库的操作什么都不能,连读取数据库都不可以.因为权限不够,只要把登录名的属性打开点击“服务器角色”,把public和sysa ...

  7. U盘删除文件时提示“文件或目录损坏且无法读取”的解决方法

    U盘删除文件时提示“文件或目录损坏且无法读取”的解决方法 出现原因:在写入或读取文件时,进行复制操作,此时复制到的文件是不完整的!或者移动硬盘/U盘中途被拔出,导致文件损坏 异常现象:被删文件(夹)属 ...

  8. SQL update select语句

    SQL update select语句 最常用的update语法是:UPDATE <table_name>SET <column_name1> = <value>, ...

  9. LeetCode 80. 删除排序数组中的重复项 II

    LeetCode 80. 删除排序数组中的重复项 II

  10. Vue学习笔记进阶篇——Render函数

    基础 Vue 推荐在绝大多数情况下使用 template 来创建你的 HTML.然而在一些场景中,你真的需要 JavaScript 的完全编程的能力,这就是 render 函数,它比 template ...