Skip to content

Commit

Permalink
Figured out the problem, don't know best way of fixing it yet:
Browse files Browse the repository at this point in the history
With each iteration, the OrderedPairs are keeping the RV that was
created in the previous runthrough of findBestRV(). Because of this,
absurdly high rhyme values are being generated for each runthrough of
the findBestRV() method. This ends up creating a sort of parabola
effect though since there is very little or no extra rhyme value being
added to OrderedPairs at the very bottom. So have to figure out an
efficient way of resetting to the original rhyme value for each ordered
pair with each runthrough.
  • Loading branch information
TomLisankie committed Mar 3, 2017
1 parent 3ae512a commit a01853c
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 43 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified src/.DS_Store
Binary file not shown.
Binary file modified src/com/.DS_Store
Binary file not shown.
Binary file modified src/com/shakenearth/.DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion src/com/shakenearth/Prhymer.java
Expand Up @@ -20,7 +20,8 @@ public class Prhymer {

public static void main(String[] args){

//0 for comparing two words and/or phrases, 1 for finding rhyming words for a specific word or phrase, 2 for a GUI.
//0 for comparing two words and/or phrases, 1 for finding rhyming words for a specific word or phrase, 2 for a GUI
// and 3 for phoneme comparison.
final int TESTING = 2;

if(TESTING == 0){ //comparing two words and/or phrases
Expand Down
2 changes: 2 additions & 0 deletions src/com/shakenearth/rhyme_essentials/Node.java
Expand Up @@ -72,6 +72,8 @@ public void findBestIndexSetAndSendItUp(){

this.setBestSet(bestSet);

System.out.println("OLD BEST: " + bestSet);

if(parentIndexSet != null){

parentIndexSet.addIndexes(bestSet.getIndexes(), bestSet.getRhymeValueForSet());
Expand Down
1 change: 1 addition & 0 deletions src/com/shakenearth/rhyme_essentials/OrderedPair.java
Expand Up @@ -179,6 +179,7 @@ public void calculateGapPenalty(int lSize) {
}

System.out.println("NEW DEDUCTION: " + deduction);
System.out.println("RV BEFORE DEDUCTION: " + getRhymeValue());

setRhymeValue(getRhymeValue() - deduction);

Expand Down
53 changes: 11 additions & 42 deletions src/com/shakenearth/rhyme_essentials/RhymeFinder.java
@@ -1,7 +1,5 @@
package com.shakenearth.rhyme_essentials;

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.nio.charset.*;
import java.nio.file.*;
import java.util.*;
Expand Down Expand Up @@ -168,45 +166,12 @@ public double newFindRhymePercentileForWords(Word word1, Word word2){
//2 - Calculate RVs
int echelon = 0;
while(cartesianProduct.size() != 0){

System.out.println("\n\nWHILE LOOP ITERATION: " + cartesianProduct.size());
System.out.println("\nCartesian Product: " + cartesianProduct);
echelon = cartesianProduct.size() - 1;
allRVs.add(findBestRV(cartesianProduct, echelon, new ArrayList<Integer>(), 0, cartesianProduct.size(),
allRVs.add(findBestRV(cartesianProduct, echelon, new ArrayList<Integer>(), 0, cartesianProduct.get(echelon).size(),
longerWord.getListOfPhonemes().size()));

//print REF CP:
/*int echelonPrint = echelon;
for(int i = 0; i < cartesianProduct.size(); i++){
ArrayList<OrderedPair> currentRow = cartesianProduct.get(i);
for(int j = 0; j < echelonPrint; j++){
System.out.print(" ");
}
for(int j = echelonPrint; j < currentRow.size(); j++){
OrderedPair pair = currentRow.get(j);
if(pair.getShorterWordPhoneme().length() == 2 && pair.getLongerWordPhoneme().length() == 2){
System.out.print(pair + " ");
}else if(pair.getShorterWordPhoneme().length() != pair.getLongerWordPhoneme().length()){
System.out.print(pair + " ");
}else if(pair.getShorterWordPhoneme().length() == 1 && pair.getLongerWordPhoneme().length() == 1){
System.out.print(pair + " ");
}
}
}*/

cartesianProduct.remove(0);
echelon = 0;

Expand Down Expand Up @@ -283,21 +248,23 @@ private ArrayList<ArrayList<OrderedPair>> findCartesianProduct(Word word1, Word

}


private double findBestRV(ArrayList<ArrayList<OrderedPair>> cpMatrix, int echelon, ArrayList<Integer> indexes,
double cumulative, int bound, int lSize){

ArrayList<OrderedPair> currentRow = cpMatrix.get(echelon); //echelon index number is the same as the current row index.

ArrayList<OrderedPair> currentRow = cpMatrix.get(echelon); //echelon number is the same as the current row index.
System.out.println("CUMULATIVE: " + cumulative);
for(int i = echelon; i < bound; i++){

currentRow.get(i).setRhymeValue(currentRow.get(i).getRhymeValue() + cumulative);;
currentRow.get(i).setRhymeValue(currentRow.get(i).getRhymeValue() + cumulative);

}

OrderedPair bestPairForRow = null;
int indexToAdd = 0;
System.out.println("\nECHELON: " + echelon);
System.out.println("BOUND: " + bound);
for(int i = echelon; i < bound; i++){

if(i == echelon){

bestPairForRow = currentRow.get(i);
Expand All @@ -322,11 +289,13 @@ private double findBestRV(ArrayList<ArrayList<OrderedPair>> cpMatrix, int echelo

bestPairForRow.setIndexes(indexes);
bestPairForRow.calculateGapPenalty(lSize);
System.out.println("ENDS ON: " + bestPairForRow);
return bestPairForRow.getRhymeValue();

}else{

echelon = echelon - 1;
System.out.println("USES: " + bestPairForRow + "\n");
return findBestRV(cpMatrix, echelon, indexes, bestPairForRow.getRhymeValue(), indexes.get(indexes.size() - 1), lSize);

}
Expand Down

0 comments on commit a01853c

Please sign in to comment.