By slightly modifying the wordcount code from the previous assignment, we can output a stopwords file.
By slightly modifying the wordcount code from the previous assignment, we can output a stopwords file.
* take all three input files as before
* take all three input files as before
* use space or "--" as tokenizer
* use `space` or `--` as tokenizer
* filter out all characters besides letters and numbers
* filter out all characters besides letters and numbers
* transform all words to lower case
* transform all words to lower case
* output is only count larger than 4000
* output is only count larger than `4000`
```java
```java
...
@@ -24,7 +24,7 @@ By slightly modifying the wordcount code from the previous assignment, we can ou
...
@@ -24,7 +24,7 @@ By slightly modifying the wordcount code from the previous assignment, we can ou
The stop word file can be found [here](https://gitlab.my.ecp.fr/2014jinwy/BDPA_Assign2_WJIN/blob/master/stopwords).
The stop word file can be found [here](https://gitlab.my.ecp.fr/2014jinwy/BDPA_Assign2_WJIN/blob/master/stopwords).
#### 2. Count word frequency of pg100.txt
#### 2. Count word frequency of pg100.txt
By using again the wordcount algorithm, we recount the word frequency for pg100.txt to be used later for word sorting. This time capital cases are kept to be taken acount in the similarity comparison. The output file can be found [here](https://gitlab.my.ecp.fr/2014jinwy/BDPA_Assign2_WJIN/blob/master/wordfreq).
By using again the wordcount algorithm, we recount the word frequency for `pg100.txt` to be used later for word sorting. This time capital cases are kept to be taken acount in the similarity comparison. The output file can be found [here](https://gitlab.my.ecp.fr/2014jinwy/BDPA_Assign2_WJIN/blob/master/wordfreq).
#### 3. Output lines
#### 3. Output lines
In this step, several tasks should be done:
In this step, several tasks should be done:
...
@@ -40,7 +40,7 @@ In this step, several tasks should be done:
...
@@ -40,7 +40,7 @@ In this step, several tasks should be done:
* sort them by their pre-calculated frequency
* sort them by their pre-calculated frequency
* output words with their line number as key
* output words with their line number as key
For this step, all task are done within the mapper. The tokenizer is " " or "--" as before. A set container is used to avoid duplicates. Java's build-in sort function is applied with a costumed compare function incorporating the word frequency. StringUtils's join function serves to join words together with a comma. The counter reveals a total of ```124787``` lines.
For this step, all task are done within the mapper. The tokenizer is `space` or `--` as before. A set container is used to avoid duplicates. Java's build-in sort function is applied with a costumed compare function incorporating the word frequency. StringUtils's join function serves to join words together with a `comma`. The counter reveals a total of `124787` lines.
@@ -78,6 +78,151 @@ The output file can be found [here](https://gitlab.my.ecp.fr/2014jinwy/BDPA_Assi
...
@@ -78,6 +78,151 @@ The output file can be found [here](https://gitlab.my.ecp.fr/2014jinwy/BDPA_Assi
---
---
### Set similarity joins
### Set similarity joins
#### 0. Primary implementation
In this part, we need compare pairwise similarity. Before we do our implementations of two approaches, several basic modules need to be done.
##### _Key Pair_
In this mapreduce program, keys emitted from mappers will be pairs of keys. Thus, an implementation of new class key pair (in our case a pair of longwritables) is needed.
Several remarks and intuition here:
* LongPair need to implement `WritableComparable` interface in order to permit shuffle and order
* Override function `equals` : We should see that order within the pairs should not be taken into account when checking two pairs are equal or not (For example : `(A,B)` should equal `(B,A)`). So our function should inverse one pair to verify inequality before yield no.
* Override function `compareTo` : The compare function has not much importance, but its difficulty lies in the necessity of coherence with `equals`. Here I proposed the method of comparing pairs by calculating a `sum` value(sum of two id) and a `difference` value(absolute difference of two id). We can check that 2 pairs can be equal if and only if pairwise difference of this two values are both zero.
To compute the similarity of two strings as instructed, we used a `Set` to store words. The advantage of set is its automatical ignorance of duplicates which enable quick calculation of union and intersection operations.