我是Pig latin的新手。我想处理下面的文件并计算最常见的单词。
的Hadoop |是|一个|开放|源|基于Java的|编程|框架|为|支持| 的|处理|和|存储|的|极其|大|数据|组|在| A |分布式|计算|。环境
该文件包含jQuery('#lp-submit-form').submit(function(e){
$this = jQuery(this);
$this.find('.preview-section .fa-angle-right').removeClass('fa-angle-right');
$this.find('.preview-section .fa').addClass('fa-spinner fa-spin');
var fd = new FormData(this);
fd.append('action', 'listingpro_submit_listing_ajax');
jQuery.ajax({
type: 'POST',
url: ajax_listingpro_submit_object.ajaxurl,
data:fd,
contentType: false,
processData: false,
success: function(res){
var resp = jQuery.parseJSON(res);
if(resp.response==="fail"){
jQuery.each(resp.status, function (k, v) {
if(k==="postTitle"){
jQuery("input:text[name='postTitle']").addClass('error-msg');
}
else if(k==="gAddress"){
jQuery("input:text[name='gAddress']").addClass('error-msg');
}
else if(k==="category"){
jQuery("#inputCategory_chosen").find('a.chosen-single').addClass('error-msg');
jQuery("#inputCategory").next('.select2-container').find('.selection').find('.select2-selection--single').addClass('error-msg');
}
else if(k==="location"){
jQuery("#inputCity_chosen").find('a.chosen-single').addClass('error-msg');
jQuery("#inputCity").next('.select2-container').find('.selection').find('.select2-selection--single').addClass('error-msg');
}
else if(k==="postContent"){
jQuery("textarea[name='postContent']").addClass('error-msg');
}
else if(k==="email"){
jQuery("input#inputEmail").addClass('error-msg');
}
});
var errorrmsg = jQuery("input[name='errorrmsg']").val();
$this.find('.preview-section .fa-spinner').removeClass('fa-spinner fa-spin');
$this.find('.preview-section .fa').addClass('fa-times');
$this.find('.preview-section').find('.error_box').text(errorrmsg).show();
}
else if(resp.response==="failure"){
jQuery("input#inputEmail").addClass('error-msg');
jQuery("input#inputEmail").after(resp.status);
$this.find('.preview-section .fa-spinner').removeClass('fa-spinner fa-spin');
$this.find('.preview-section .fa').addClass('fa-angle-right');
}
else if(resp.response==="success"){
$this.find('.preview-section .fa-spinner').removeClass('fa-times');
$this.find('.preview-section .fa-spinner').removeClass('fa-spinner fa-spin');
$this.find('.preview-section .fa').addClass('fa-check');
var redURL = resp.status;
function redirectPageNow(){
window.location.href= redURL;
}
setTimeout(redirectPageNow, 1000);
}
},
error: function(request, error){
alert(error);
}
});
e.preventDefault();
});
作为分隔符。
答案 0 :(得分:0)
有很多单词计数示例的例子。无论如何,这里是带分隔符的那个'|'
lines = LOAD 'input.txt' AS (line:chararray);
newlines = FOREACH lines GENERATE REPLACE(line,'\\|',' ') AS newline;
words = FOREACH newlines GENERATE FLATTEN(TOKENIZE(newline)) as word;
grouped = GROUP words BY word;
w_count = FOREACH grouped GENERATE group, COUNT(words);
DUMP w_count;