Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/org/sifarish/common/BusinessGoalInjector.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected void reduce(Tuple key, Iterable<Tuple> values, Context context)
throws IOException, InterruptedException {
boolean first = true;
Tuple bizScore = null;
boolean toSkip = false;
boolean toSkip;
for(Tuple value : values) {
toSkip = false;
if (first) {
Expand All @@ -178,7 +178,7 @@ protected void reduce(Tuple key, Iterable<Tuple> values, Context context)
}
first = false;
} else {
int weightedScore = 0;
int weightedScore;
if (null != bizScore) {
//weighted average score
int sumWeightedScore = recWt * value.getInt(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void setEventScores(List<EngagementScore> eventScores) {
* @return
*/
public int scoreForEvent(int eventType, int count) {
int score = 0;
int score;

//match event type
EngagementScore thisScore = null;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sifarish/common/IndividualNovelty.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public String[] tranform(String value) {
rating = (rating * maxRating) / maxRatingInData;
}

Integer novelty = null;
Integer novelty;
if (rating == 0) {
novelty = maxRating;
} else if (rating == maxRating){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private void loadSemanticMatcherParams(Configuration conf, Map<String, Object> p
*/
protected void reduce(Tuple key, Iterable<Text> values, Context context)
throws IOException, InterruptedException {
double dist = 0;
double dist;
intLength = -1;

valueList.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sifarish/common/NewItemUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ protected void reduce(Tuple key, Iterable<Tuple> values, Context context)
* @return
*/
private int aggregateRating() {
int aggrRating = 0;
int aggrRating;
if (ratingAggrStrategy.equals("average")) {
int sum = 0;
for (int rating : newItemPredRatings) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sifarish/common/UtilityPredictor.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ protected void map(LongWritable key, Text value, Context context)
//user rating
context.getCounter("Record type count", "Rating").increment(1);

boolean toInclude = true;
boolean toInclude;
for (int i = 1; i < items.length; ++i) {
//all user ratings for this item
ratings = items[i].split(subFieldDelim);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sifarish/etl/CountryStandardFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public abstract class CountryStandardFormat {
* @return
*/
public static CountryStandardFormat createCountryStandardFormat(String country, StructuredTextNormalizer textNormalizer) {
CountryStandardFormat countryFormat = null;
CountryStandardFormat countryFormat;
if (country.equals("USA")) {
countryFormat = new UnitedStatesStandardFormat(textNormalizer);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class CharacterPairSimilarity extends DynamicAttrSimilarityStrategy {
* @see org.sifarish.feature.DynamicAttrSimilarityStrategy#findDistance(java.lang.String, java.lang.String)
*/
public double findDistance(String src, String target) throws IOException {
double dist = 0;
double dist;
String[] srcTerms = src.split(fieldDelimRegex);
List<String> srcPairs = getCharacterPairs(srcTerms);
String[] trgTerms = target.split(fieldDelimRegex);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sifarish/feature/CosineSimilarity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class CosineSimilarity extends DynamicAttrSimilarityStrategy{
*/
@Override
public double findDistance(String src, String target) {
double distance = 1.0;
double distance;
countVec.clear();
intersectionLength = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/sifarish/feature/DiffTypeSimilarity.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,11 @@ protected void reduce(LongWritable key, Iterable<Text> values, Context context)
* @throws IOException
*/
private int findSimilarity(String source, String target, Context context) throws IOException {
int sim = 0;
int sim;
mapFields(source, context);
String[] trgItems = target.split(fieldDelimRegex);

double dist = 0;
double dist;
context.getCounter("Data", "Target Field Count").increment(targetFields.size());
if (prntDetail){
System.out.println("target record: " + trgItems[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public String[] getMatchingContexts() {
*/
public static DynamicAttrSimilarityStrategy createSimilarityStrategy(String algorithm, Map<String,Object> params)
throws IOException {
DynamicAttrSimilarityStrategy simStrategy = null;
DynamicAttrSimilarityStrategy simStrategy;
if (algorithm.equals("jaccard")){
double srcNonMatchingTermWeight = (Double)params.get("srcNonMatchingTermWeight");
double trgNonMatchingTermWeight = (Double)params.get("trgNonMatchingTermWeight");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public EditDistanceSimilarity(boolean tokenWise) {
*/
@Override
public double findDistance(String src, String target) {
double distance = 0;
double distance;
if (tokenWise) {
distance = findDistanceTokenWise( src, target);
} else {
Expand All @@ -62,7 +62,7 @@ public double findDistance(String src, String target) {
*/
private double findDistanceTokenWise(String src, String target) {
double distance = 0;
int editDistance = 0;
int editDistance;
//System.out.println("findDistanceTokenWise:" + src + ":" + target);

String[] srcTerms = src.split(fieldDelimRegex);
Expand Down Expand Up @@ -118,7 +118,7 @@ private double findDistanceTokenWise(String src, String target) {
*/
private double findDistanceFieldWise(String src, String target) {
double distance = 0;
int editDistance = 0;
int editDistance;
sequences.clear();
maxSeqLength = 0;
generateSubSequences(src, true);
Expand All @@ -143,7 +143,7 @@ private void generateSubSequences(String token, boolean store) {
}
}

String subToken = null;
String subToken;
if (len > MIN_TOKEN_LENGTH ) {
//create sub sequences by taking one char out and make recursive call
for (int i = 0; i < len; ++i) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/sifarish/feature/EuclideanDistance.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public EuclideanDistance(int scale) {
*/
public void accumulate(double distance, double weight){
distance = Math.abs(distance);
double effectDist = 0;
double effectDist;
//if weight < 1 then convex i.e. effective distance greater than distance otherwise concave
effectDist = (1 / weight) * distance + ( 1 - 1 / weight) * distance * distance;

Expand Down Expand Up @@ -77,7 +77,7 @@ public int getSimilarity() {

@Override
public double getSimilarity(boolean isScaled) {
double sim = 0;
double sim;
if (isScaled) {
sim = ((Math.sqrt(sumWt) * scale) / count);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sifarish/feature/JaccardSimilarity.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public JaccardSimilarity(double srcNonMatchingTermWeight, double trgNonMatchingT
*/
@Override
public double findDistance(String src, String target) {
double distance = 1.0;
double distance;

String[] srcTerms = src.split(fieldDelimRegex);
String[] trgTerms = target.split(fieldDelimRegex);
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/sifarish/feature/RecordDistanceFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public int findDistance(String[] firstItems, String[] secondItems) throws IOExce
String firstId = firstItems[idOrdinal];
String secondId = secondItems[idOrdinal];

int netDist = 0;
int netDist;

//if inter set matching with mixed in sets, match only same ID from different sets
if (mixedInSets) {
Expand Down Expand Up @@ -194,15 +194,15 @@ public int findDistance(String[] firstItems, String[] secondItems) throws IOExce
}

//extract fields
String firstAttr = "";
String firstAttr;
if (field.getOrdinal() < firstItems.length ){
firstAttr = firstItems[field.getOrdinal()];
} else {
throw new IOException("Invalid field ordinal. Looking for field " + field.getOrdinal() +
" found " + firstItems.length + " fields in the record starting with :" + firstItems[0]);
}

String secondAttr = "";
String secondAttr;
if (field.getOrdinal() < secondItems.length ){
secondAttr = secondItems[field.getOrdinal()];
}else {
Expand Down Expand Up @@ -281,7 +281,7 @@ public int findDistance(String[] firstItems, String[] secondItems) throws IOExce
* @throws IOException
*/
private double textDistance(Field field, String firstAttr, String secondAttr) throws IOException {
double dist = 0;
double dist;
if (field.getDataSubType() == Field.TEXT_TYPE_PERSON_NAME) {
dist = personNameDistance(field, firstAttr, secondAttr);
} if (field.getDataSubType() == Field.TEXT_TYPE_STREET_ADDRESS) {
Expand Down Expand Up @@ -380,7 +380,7 @@ private double hourWindowDistance(Field field, String firstAttr, String secondAt
* @return
*/
private double locationDistance(Field field, String firstAttr, String secondAttr) {
double dist = 0;
double dist;
String[] subFields = firstAttr.split(subFieldDelim);
Location firstLocation = new Location( subFields[0], subFields[1], subFields[2]);
subFields = secondAttr.split(subFieldDelim);
Expand Down Expand Up @@ -459,7 +459,7 @@ private double eventDistance(Field field, String firstAttr, String secondAttr) {
* @throws IOException
*/
private double personNameDistance(Field field, String firstAttr, String secondAttr) throws IOException {
double dist = 0;
double dist;
String[] firstItems = firstAttr.split("\\s+");
String[] secondItems = secondAttr.split("\\s+");
double firstNameDist = textSimStrategy.findDistance(firstItems[0], secondItems[0]);
Expand All @@ -477,7 +477,7 @@ private double personNameDistance(Field field, String firstAttr, String secondAt
* @throws IOException
*/
private double streetAddressDistance(Field field, String firstAttr, String secondAttr) throws IOException {
double dist = 0;
double dist;
String[] firstStreetCoponents = getStreetComponents(firstAttr);
String[] secondStreetCoponents = getStreetComponents(secondAttr);
dist = textSimStrategy.findDistance(firstStreetCoponents[0], secondStreetCoponents[0]) * field.getPartWeights()[0] +
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/sifarish/feature/SameTypeSimilarity.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ protected void reduce(TextIntInt key, Iterable<Text> values, Context context)
*/
private int findDistance(String first, String second, Context context) throws IOException {
//LOG.debug("findDistance:" + first + " " + second);
int netDist = 0;
int netDist;

//if inter set matching with mixed in sets, match only same ID from different sets
if (mixedInSets) {
Expand Down Expand Up @@ -438,15 +438,15 @@ private int findDistance(String first, String second, Context context) throws IO
}

//extract fields
String firstAttr = "";
String firstAttr;
if (field.getOrdinal() < firstItems.length ){
firstAttr = firstItems[field.getOrdinal()];
} else {
throw new IOException("Invalid field ordinal. Looking for field " + field.getOrdinal() +
" found " + firstItems.length + " fields in the record:" + first);
}

String secondAttr = "";
String secondAttr;
if (field.getOrdinal() < secondItems.length ){
secondAttr = secondItems[field.getOrdinal()];
}else {
Expand Down Expand Up @@ -686,7 +686,7 @@ private double hourWindowDistance(Field field, String firstAttr, String secondAt
* @return
*/
private double locationDistance(Field field, String firstAttr, String secondAttr,Context context) {
double dist = 0;
double dist;
String[] subFields = firstAttr.split(subFieldDelim);
Location firstLocation = new Location( subFields[0], subFields[1], subFields[2]);
subFields = secondAttr.split(subFieldDelim);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sifarish/feature/TopMatches.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ protected void reduce(Tuple key, Iterable<Text> values, Context context)
throws IOException, InterruptedException {
srcEntityId = key.getString(0);
count = 0;
boolean doEmitNeighbor = false;
boolean doEmitNeighbor;
valueList.clear();
for (Text value : values){
doEmitNeighbor = false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sifarish/social/ItemRatingStat.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ protected void cleanup(Context context)
" maxRatingStdDev:" + maxRatingStdDev + " maxCount:" + maxCount);
tupleList.close();
tupleList.open(BigTupleList.Mode.Read);
Tuple value = null;
Tuple value;
while ((value = tupleList.read()) != null) {
thisCount = value.getInt(COUNT_ORD + 1) * statsScale / maxCount;
thisRatingMean = value.getInt(MEAN_ORD + 1) * statsScale / maxRatingMean ;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/sifarish/social/PearsonCorrelator.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ private void createValueTuple(Integer secKey, String[] items) {
valueHolder.add(secKey, items[0]);

//all userID and rating pair
String[] subItems = null;
String userID = null;
Integer rating = 0;
String[] subItems;
String userID;
Integer rating;
for (int i = 1; i < items.length; ++ i) {
subItems = items[i].split(subFieldDelim);
userID = subItems[0];
Expand Down Expand Up @@ -216,8 +216,8 @@ protected void reduce(Tuple key, Iterable<Tuple> values, Context context)
throws IOException, InterruptedException {

int hashPair = key.getInt(0);
UserRating userRating = null;
UserRating userRatingSecond = null;
UserRating userRating;
UserRating userRatingSecond;
if (hashPair / hashPairMult == hashPair % hashPairMult){
//same bucket
userRatings.clear();
Expand Down Expand Up @@ -409,7 +409,7 @@ public int getMatchedRating(int index) {
public void calculateStat() {
int ratingSum = 0;
int ratingSquareSum = 0;
int rating = 0;
int rating;

for (int index : matchedRatings) {
rating = ratings.get(index).getRight();
Expand Down Expand Up @@ -440,7 +440,7 @@ public int getRatingStdDev() {
* @return
*/
public int[] findCoVarianceItems(int[] coVarItems) {
int normRating = 0;
int normRating;
if (null == coVarItems) {
coVarItems = new int[matchedRatings.size()];
for (int i =0; i < matchedRatings.size(); ++i) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sifarish/social/RatingDifference.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected void setup(Context context) throws IOException, InterruptedException {
protected void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
String[] items = value.toString().split(fieldDelim);
String[] ratings = null;
String[] ratings;
for (int i = 1; i < items.length; ++i) {
ratings = items[i].split(subFieldDelim);
String itemOne = ratings[0];
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/sifarish/util/Field.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public double findDistance(String thisValue, String thatValue) {
* @return
*/
public double findDistance(int thisValue, int thatValue, double diffThreshold) {
double distance = 1.0;
double distance;
if (max > min) {
distance = ((double)(thisValue - thatValue)) / (max - min);
} else {
Expand All @@ -268,7 +268,7 @@ public double findDistance(int thisValue, int thatValue, double diffThreshold)
* @return
*/
public double findDistance(double thisValue, double thatValue, double diffThreshold) {
double distance = 1.0;
double distance;
if (max > min) {
distance = ((thisValue - thatValue)) / (max - min);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sifarish/util/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public double distance(StructuredAttribute otherAttr, Field field) {
double[] weights = field.getComponentWeights();
Location other = (Location)otherAttr;
distStrategy.initialize();
double dist = 0;
double dist;
if (null != landMark) {
dist = (landMark.equals(other.landMark)? 0 : 1);
distStrategy.accumulate(dist, weights[0]);
Expand Down