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. HTML5 Differences from HTML4

    Abstract "HTML5 Differences from HTML4" describes the differences of the HTML5 specificati ...

  2. group by 并且 count(1)的linq写法

    SELECT [MobleNo],count(1) FROM [CustMobleNo] group by [MobleNo] GO ===作用等于=== var rst = from c in da ...

  3. Python SGMLParser 的1个BUG??

    首先说一下,我用的是python 2.7,刚好在学Python,今天想去爬点图片当壁纸,但是当我用 SGMLParser 做 <img> 标签解析的时候,发现我想要的那部分根本没获取到,我 ...

  4. poj 2187 N个点中输出2点的最大距离的平方

    旋转卡壳 Sample Input 40 00 11 11 0Sample Output 2 # include <iostream> # include <cstdio> # ...

  5. hdoj2546 饭卡(DP,01背包)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=2546 思路 首先要判断卡里的钱是不是大于等于5元,如果不足5元,直接输出余额:如果大于等于5元,则先留 ...

  6. Html5游戏开发攻略(免费的音乐面包篇)

    这一篇我们来尝尝免费的面包,至少目前是这样的. QQ音乐相信大家或多或少都使用过,里面的音乐资源非常多. 这个时候你可能就明白了,没错,我们要在游戏中使用QQ音乐的资源当背景音乐~~~~~哦耶~! 咳 ...

  7. Xposed模块开发教程

    转:http://vbill.github.io/2015/02/10/xposed-1/     http://blog.csdn.net/zhangmiaoping23/article/detai ...

  8. 全局设置axios发送cookie(axios 默认不发送cookie)

    import axios from 'axios' axios.defaults.withCredentials=true; 如图:

  9. PHP会话——模拟购物车的功能

    1.php默认是不开启会话的,要使用会话用两种方法:(1)使用session_start();显示的开启会话.(2)在php.ini中找到如下的一行:找到session.auto_start = 0, ...

  10. Python面向对象中super用法与MRO机制

    1. 引言 最近在研究django rest_framework的源码,老是遇到super,搞得一团蒙,多番查看各路大神博客,总算明白了一点,今天做一点总结. 2. 为什么要用super 1)让代码维 ...