-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Codigo para las funciones del test. #69
base: master
Are you sure you want to change the base?
Conversation
src/test/java/nearsoft/academy/bigdata/recommendation/MovieRecommender.java
Show resolved
Hide resolved
BufferedReader br = new BufferedReader(new FileReader(file)); | ||
FileWriter writer = new FileWriter("data.csv"); | ||
BufferedWriter bw = new BufferedWriter(writer); | ||
String csv = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why string? Did you consider a string builder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't consider the inefficiency of string vs. stringBuilder in this case. I'll keep it in mind for the next occasion I do something similar.
private int reviews; | ||
private long users; | ||
private int products; | ||
public UserBasedRecommender recommender; | ||
private HashMap<String, Integer> productTable = new HashMap(); | ||
private HashMap<String, Long> userTable = new HashMap(); | ||
private HashMap<Integer, String> iProductsTable = new HashMap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need all of these as global variables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all of them, but I decided to leave all of them like that instead of a few regarding the aesthetics. I'll consider not doing this again on a future case.
} | ||
|
||
public List<String> getRecommendationsForUser(String user) throws Exception { | ||
List<String> results = new ArrayList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ArrayList and not LinkedList?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the list consisted only of three elements and the order wasn't an issue. Also no removal or rearrangement was needed, so I thought an arrayList was more fitting for this specific case.
Created and implemented a new class called MovieRecommender.java.
This new class creates a .csv file for reading from a .txt file of Amazon reviews. This class has 5 methods: "readReviewsFile" which receives the .txt file and generates a .csv file for its reading. "getTotalReviews", "getTotalProducts" and "getTotalUsers" were each of this gets an integer value (except for users which is a long) that represents the total amount of reviews, products and users respectively. "getRecommendationsForUser" receives a user id and generates product recommendations for that user (in this case 3 recommendations are given).