From: aaronshaw Date: Tue, 1 Jul 2014 00:25:40 +0000 (-0500) Subject: tweaks based on testing on Aaron's system. mostly grammar/syntax clarifications X-Git-Url: https://projects.mako.cc/source/redirect-tools/commitdiff_plain/f147e395e2aba333ca5322339a8b1746b2a0b19d tweaks based on testing on Aaron's system. mostly grammar/syntax clarifications --- diff --git a/README.rst b/README.rst index f1dcc81..081f765 100644 --- a/README.rst +++ b/README.rst @@ -32,15 +32,9 @@ Wikipedia`__ that I downloaded with the following command:: __ https://simple.wikipedia.org/ -Before you start, you may also want to change the default directories -for writing intermediate output files. The default directories for -writing and reading files are at the top of the file `redirect_tools.R` -and can be changed by editing that file. By default, all files will be -written to the subdirectory "./output" in the local directory. If you -want to use the default directories, you will still need to create them -with a command like this:: +Before you start, you may also want to change the default directories for writing intermediate output files. The default directories for writing and reading files are at the top of the file `redirect_tools.R` and can be changed by editing that file. By default, all files will be written to the subdirectory "./output" in the local directory. If you want to use the default directories, you will still need to create them with a command like this:: - mkdir output/redir output/spells + mkdir output; output/redir; output/spells Step 2: Find Redirects in Revisions ======================================================================= @@ -58,11 +52,9 @@ Output: - bzip2 compressed TSV files (one line per revision) -Run the file `01-extract_redirects.py` to build a dataset of revisions or edits -that marks every revisions as either containinig a revision, or not. +You will run the `01-extract_redirects.py` script to build a dataset of revisions or edits that marks every revisions as either containinig a revision, or not. -The script `01-extract_redirects.py` takes a MediaWiki dump file on STDIN and -outputs a TSV file on STDOUT of the following form. +Then, the script `01-extract_redirects.py` will take a MediaWiki dump file on STDIN and output a TSV file on STDOUT of the following form. +---------+-------------+--------------------------------+------------+---------+----------+--------------------+ | page.id | revision.id | page.title | timestamp | deleted | redirect | target | @@ -72,21 +64,14 @@ outputs a TSV file on STDOUT of the following form. +---------+-------------+--------------------------------+------------+---------+----------+--------------------+ -In this case, the first revision of the article "Mikhail Alekseevich -Lavrentiev" was not a redirect but the second is a redirect to "Mikhail -Lavrentyev". +In this (example) case, the first revision of the article "Mikhail Alekseevich Lavrentiev" was not a redirect but the second is a redirect to "Mikhail Lavrentyev." -If you were using the Simple English dump (which is a single file) I would -run the following command to send the output to the default :: +If you are using the Simple English dump (which is a single file) you would run the following command to send the output to the default destination:: 7za x -so simplewiki-20140410-pages-meta-history.xml.7z | python2.7 01-extract_redirects.py | bzip2 -c - > output/redir/simple_redirs.tsz.bz2 -Because our dumpfile is 7z compressed, I used 7za to uncompress it. If I had -used a gzip or bzip compressed file, I would use `zcat` or `bzcat` instead. I'm -also catting the output to `bzip2 -c` which will bzip the TSV output to -conserve space. The next step assumes a bzip2 compressed file. If you don't -want to bzip2 compress, you'll need to modify the code. +Because our dumpfile is 7z compressed, I used 7za to uncompress it. If I had used a gzip or bzip compressed file, I would use `zcat` or `bzcat` instead. I'm also catting the output to `bzip2 -c` which will bzip the TSV output to conserve space. The next step assumes a bzip2 compressed file. If you don't want to use bzip2 to compress, you'll need to modify the code. Step 2: Generate spells @@ -102,16 +87,16 @@ Input: - bzip compressed TSV files -Outp1ut: +Output: -- RData files containing data.frame of redirect spells named `redirect.spell` +- RData files containing a data.frame of redirect spells named `redirect.spell` (one file per input file) - Stata DTA file (same data) - TSV file (same data) The file `redirect_tools.R` contains an R function `generate.spells()` that -takes a data frame of edit data as created in step 1 and a list of page title -and which will create a list of redirect spells for those pages. It also +takes a data frame of edit data as created in step 1 and a list of page titles +in order to create a list of redirect spells for those pages. It also contains a function `filename.to.spells()` which takes the filename of a bzip compressed file of the form created in step 1 and outputs a full list of redirect spells.