Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LMBarrera
Copy link

@LMBarrera LMBarrera commented Oct 7, 2019

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).

BufferedReader br = new BufferedReader(new FileReader(file));
FileWriter writer = new FileWriter("data.csv");
BufferedWriter bw = new BufferedWriter(writer);
String csv = "";

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?

Copy link
Author

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.

Comment on lines +20 to +26
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();

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?

Copy link
Author

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();

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?

Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants