title: Pig Latin Word Count
body: <p>I am trying to count number of lines that contain the following words: <code>'jack', 'hack', 'mat', 'throttle'</code> in a pig script. I am using Cloudera quickstart vm.</p>
  
  <p>The input file is:</p>
  
  <pre><code>09-jack-17,5:00PM;#slowmotion,Tribune Logic hack: how is life in temrs of money Creative hack
  
  14-June-18,7:15PM;#Indiacalling,Horton-NJ Strategic/Halloween One World at Application Deployment
  
  12-jack-16,jfh:er;#temporary, accomodation, osteoporosis, juxtapose, don't misinterpret this awaiting throttle jack
  </code></pre>
  
  <p>The output should be:
  hack 2
  jack 2
  throttle 1
  mat 0
  I am unable to extract those words and  calculate it's count. What should I do?
  I tried the following script which was given by inquisitive_mind:</p>
  
  <pre><code>A = LOAD 'Input.txt'AS(line: chararray);
  SPLIT A INTO M IF line matches'hackathon,N IF line matches'dec', O IF line matches'chicago',P IF line matches'java';
  M1 = GROUP M ALL;
  M2 = FOR EACH M1 GENERATE COUNT(M);
  M3 = FOREACH M2 GENERATE CONCAT('hackathon',(chararray)M2.$0);
  N1 = GROUP N ALL;
  N2 = FOREACH N1 GENERATE COUNT(N);
  N3 = FOREACHN2 GENERATE CONCAT('dec',(chararray)N2.$0);
  O1 = GROUP O ALL;
  O2 = FOREACH O1 GENERATE COUNT(O);
  O3 = FOR EACH O2 GENERATE CONCAT('chicago',(chararray)O2.$0);
  P1 = GROUP P ALL;
  P2 = FOR EACH P1 GENERATE COUNT(P);
  P3 = FOREACH P2 GENERATE CONCAT('java',(chararray)P2.$0);
  DUMP M3;
  DUMP N3;
  DUMP O3;
  DUMP P3;
  </code></pre>
  
  <p>But when I run it in mapreduce or local mode I get the following error:</p>
  
  <p>2016-10-11 09:43:44,084 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1000: Error during parsing. Lexical error at line 19, column 0.  Encountered:  after : ""  Details at logfile: /home/cloudera/pig_1476204218406.log</p>
  
  <p>Here is the logfile:</p>
  
  <h2>Pig Stack Trace</h2>
  
  <pre><code>ERROR 1000: Error during parsing. Lexical error at line 19, column 0.  Encountered: &lt;EOF&gt; after : ""
  
  org.apache.pig.tools.pigscript.parser.TokenMgrError: Lexical error at line 19, column 0.  Encountered: &lt;EOF&gt; after : ""
      at org.apache.pig.tools.pigscript.parser.PigScriptParserTokenManager.getNextToken(PigScriptParserTokenManager.java:3326)
      at org.apache.pig.tools.pigscript.parser.PigScriptParser.jj_ntk(PigScriptParser.java:1379)
      at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:106)
      at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:198)
      at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:173)
      at org.apache.pig.tools.grunt.Grunt.exec(Grunt.java:84)
      at org.apache.pig.Main.run(Main.java:613)
      at org.apache.pig.Main.main(Main.java:158)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
      at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
  </code></pre>