Improve search accuracy using nutch

Source: Internet
Author: User

PrivateBooleanGettexthelper (stringbufferSB,NodeNode, 
  BooleanAbortonnestedanchors,
  IntAnchordepth){
  If("Script". equalsignorecase (node. getnodename ())){
  ReturnFalse;
  }
  If("Style". inclusignorecase (node. getnodename ())){
  ReturnFalse;
  }
  If(Abortonnestedanchors&&"A". inclusignorecase (node. getnodename ())){
  Anchordepth ++;
  If(Anchordepth>1)
  ReturnTrue;
  }
  If(Node. getnodetype ()=Node. comment_node){
  ReturnFalse;
  }

  If(Node. getnodetype ()=Node. text_node){// Node is the content contained in the parsed webpage source file.

  // Node. text_node: the node belongs to the text node <body> <div> <Href> <TD> and other labels
  //CleanupAndTrimTheValue 
  StringText=Node. getnodevalue ();// Get the text content in the node, which is equivalent to removing the HTML Tag

  
  Text=Text. replaceall ("// s+ ","");
  Text=Text. Replace ("【","");
  Text=Text. Replace ("]","");
  Text=Text. Replace ("[","");
  Text=Text. Replace ("]","");
  Text=Text. Replace ("| ","");
  Text=Text. Replace ("success ","");
  Text=Text. Replace ("? ","");
  Text=Text. Replace ("? ","");
  Text=Text. Replace ("? ","");
  Text=Text. Replace ("| ","");
  Text=Text. Replace (",","");
  Text=Text. Replace ("-","");
  Text=Text. Replace ("~ ","");
  Text=Text. Replace ("! ","");
  Text=Text. Replace ("@","");
  Text=Text. Replace ("#","");
  Text=Text. Replace ("$ ","");
  Text=Text. Replace ("^ ","");
  Text=Text. Replace ("*","");
  Text=Text. Replace ("(","");
  Text=Text. Replace (")","");
  Text=Text. Replace ("% ","");
  Text=Text. Replace ("> ","");
  Text=Text. Replace ("? ","");
  Text=Text. Replace ("% ","");

  Text=Text. Trim ();

  Temp=Node. getparentnode (). tostring ();// Obtain the label of the parent node

  If(Text. Length ()>0&&Temp. indexof (":")=-1){// If it belongs to <Href>, filter...

  If(Sb. Length ()>0)SB. append ('');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.