concept Reuters wire news item in category graphx

This is an excerpt from Manning's book Spark GraphX in Action.
In this example, we download Reuters wire news items from 1987 and use LDA to infer the topics and tell us how each document scores in each of the topics. Listing 7.3 shows how to download this data from the University of California, Irvine’s Knowledge Discovery in Databases Archive, and then how to clean this data using Linux/OSX shell commands. To do the cleaning, it uses a lot of tricks with tools like sed and tr. If you aren’t familiar with these commands, you can seek out a book or web resource that explains them. The Reuters data is in the form of SGML, which is a kind of a predecessor to HTML. For each news item, we’re interested in the text between the <BODY> and </BODY> tags. For convenient Spark processing of a text file, we want it to be one news item per line (so some of the resulting lines are fairly long).
Listing 7.3. Downloading and cleaning the Reuters wire news items
wget https://archive.ics.uci.edu/ml/machine-learning-databases/ reuters21578-mld/reuters21578.tar.gz tar -xzvf reuters21578.tar.gz reut2-000.sgm cat reut2-000.sgm | tr '\n' ' ' | sed -e 's/<\/BODY>/\n/g' | sed -e 's/^.*<BODY>//' | tr -cd '[[:alpha:]] \n' >rcorpus