A quick introduction to the MapReduce program to find a crossword puzzle of the same alphabet

Source: Internet
Author: User
Tags hadoop fs

Find all the words of the same word. Now, take part of the dataset (below) to complete the project.

Project requirements

An English book contains thousands of words or phrases, and now we need to find all the anagrams (crossword puzzles) of the same alphabet in a large number of words.

Thinking analysis

Based on the above requirements, we have completed the following steps:

1. In the Map stage, each word (word) is sorted alphabetically by Sortedword and then output key/value key value pair (Sortedword,word).

2. In the Reduce phase, all anagrams (crossword puzzles) of the same letter group are counted.

1 First, open the MyEclipse,

Under Com.dajiangtai.hadoop.test package, create a new anagram class. Add the Main method.

2. Under the following folder, create a new anagram folder

3 Uploading a data source Anagram.txt

In the location of the Anagram folder, right-click, upload fles to DFS,

4, write the code in the Anagram.java. See Anagram.java.txt

Once the code is written, you can then run the 1 Java application.

After the refresh, the following.

5, Next, click part-r-00000 (186.1 kb,r3), then appear.

Well, at the moment, it's running successfully locally.

6, now, need to go to the cluster to run successfully, how to do it?

Export, Hadoop, export,

Java, JAR file, next

7, because, in Hadoop, these dependent racks are there, so we do not need to superfluous again packaging.

Take a name for the rack package, for Anagram.jar, first create a new folder jar in the D disk, store it in D:\JAR\anagram.jar, and click Finish.

8. Next, use Xshell to connect to CentOS.

9, RZ, open D:\JAR\anagram.jar, upload to CentOS

10. Execution of Orders

Hadoop jar Anagram.jar com.dajiangtai.hadoop.test.anagram/anagram//anagram/out/

11. View Results

Hadoop fs-text/anagram/out/part-r-00000

A quick introduction to the MapReduce program to find a crossword puzzle of the same alphabet

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.