<commit_before>/**
 * Copyright 2014 McGill University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package ca.mcgill.cs.creco.data;

import java.util.Collections;
import java.util.HashMap;

import ca.mcgill.cs.creco.data.json.ProductStub;
import ca.mcgill.cs.creco.data.json.RatingStub;
import ca.mcgill.cs.creco.data.json.SpecStub;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class Product 
{
	// Fields directly copied from CR Data fields
	private String mpn;
	private String id;
	private String imageLarge;
	private String imageThumbnail;
	private String displayName;
	private String name;
	private String upc;
	private String overallScoreDisplayName;
	private String modelOverviewPageUrl;
	private String genericColor;
	private String review;
	private String highs;
	private String lows;
	private String bottomLine;
	private String description;
	private String dontBuyType;
	private Double overallScoreMax;
	private Double overallScoreMin; 
	private Double overallScore;
	private Boolean isRecommended;
	private Boolean isBestSeller;
	private Boolean isTested;
	private Boolean isBestBuy;
		
	// Derived fields
	private int numRatings;
	private HashMap<String, Rating> ratings;
	private HashMap<String, Spec> specs;
	private String brandId;
	private String brandName;
	private Double price;
	private String categoryId;
	private Category category;
	
	Product(ProductStub prodStub) 
	{
		// Copy fields from the stub
		this.mpn = prodStub.mpn;                    
		this.id = prodStub.id;                     
		this.imageLarge = prodStub.imageLarge;             
		this.imageThumbnail = prodStub.imageThumbnail;         
		this.displayName = prodStub.displayName;            
		this.name = prodStub.name;                   
		this.upc = prodStub.upc;                    
		this.overallScoreDisplayName = prodStub.overallScoreDisplayName;
		this.modelOverviewPageUrl = prodStub.modelOverviewPageUrl;   
		this.genericColor = prodStub.genericColor;           
		this.review = prodStub.review;                 
		this.highs = prodStub.highs;                  
		this.lows = prodStub.lows;                   
		this.bottomLine = prodStub.bottomLine;             
		this.description = prodStub.description;            
		this.dontBuyType = prodStub.dontBuyType;            
		this.overallScoreMax = prodStub.overallScoreMax;
		this.overallScoreMin = prodStub.overallScoreMin;
		this.overallScore = prodStub.overallScore;   
		if(prodStub.price != null)
		{
			this.price = prodStub.price.value;
		}
		this.isRecommended = prodStub.isRecommended; 
		this.isBestSeller = prodStub.isBestSeller;  
		this.isTested = prodStub.isTested;      
		this.isBestBuy = prodStub.isBestBuy;
		
		// Calculate derived fields
		this.categoryId = prodStub.category.id;
		this.brandId = (prodStub.brand != null)? prodStub.brand.id : null;
		this.brandName = (prodStub.brand != null)? prodStub.brand.displayName : null;
		
		this.specs = new HashMap<String, Spec>();
		if(prodStub.specs != null)
		{
			for(SpecStub spec : prodStub.specs)
			{
				this.specs.put(spec.attributeId, new Spec(spec));
			}
		}
		
		this.numRatings = 0;
		this.ratings = new HashMap<String, Rating>();
		if(prodStub.ratings != null)
		{
			for(RatingStub rating : prodStub.ratings)
			{
				this.ratings.put(rating.attributeId, new Rating(rating));
				this.numRatings++;
			}
		}
	}
	
	void setCategory(Category pCategory)
	{
		category = pCategory;
	}
	
	/**
	 * @return The category ID.
	 */
	public String getCategoryId() 
	{ return categoryId; }
	
	/**
	 * @return The number of ratings.
	 */
	public int getNumRatings() 
	{ return numRatings; }

	public String getMpn() {
		return mpn;
	}

	public String getId() {
		return id;
	}

	public String getImageLarge() {
		return imageLarge;
	}

	public String getImageThumbnail() {
		return imageThumbnail;
	}

	public String getName() {
		return displayName;
	}
	
	public String getName_()
	{
		return name;
	}

	public String getUpc() {
		return upc;
	}

	public String getOverallScoreDisplayName() {
		return overallScoreDisplayName;
	}

	public String getModelOverviewPageUrl() {
		return modelOverviewPageUrl;
	}

	public String getGenericColor() {
		return genericColor;
	}

	public String getReview() {
		return review;
	}

	public String getHighs() {
		return highs;
	}

	public String getLows() {
		return lows;
	}

	public String getBottomLine() {
		return bottomLine;
	}

	public String getDescription() {
		return description;
	}

	public String getDontBuyType() {
		return dontBuyType;
	}<commit_msg>#22 Removed some unused fields from Product<commit_after>/**
 * Copyright 2014 McGill University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package ca.mcgill.cs.creco.data;

import java.util.Collections;
import java.util.HashMap;

import ca.mcgill.cs.creco.data.json.ProductStub;
import ca.mcgill.cs.creco.data.json.RatingStub;
import ca.mcgill.cs.creco.data.json.SpecStub;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class Product 
{
	// Fields directly copied from CR Data fields
	private String id;
	private String displayName;
	private String review;
	private String highs;
	private String lows;
	private String bottomLine;
	private String description;
	private String dontBuyType;
	private Double overallScoreMax;
	private Double overallScoreMin; 
	private Double overallScore;
	private Boolean isRecommended;
	private Boolean isBestSeller;
	private Boolean isTested;
	private Boolean isBestBuy;
		
	// Derived fields
	private int numRatings;
	private HashMap<String, Rating> ratings;
	private HashMap<String, Spec> specs;
	private String brandId;
	private String brandName;
	private Double price;
	private String categoryId;
	private Category category;
	
	Product(ProductStub prodStub) 
	{
		// Copy fields from the stub
		this.id = prodStub.id;                     
		this.displayName = prodStub.displayName;            
		this.review = prodStub.review;                 
		this.highs = prodStub.highs;                  
		this.lows = prodStub.lows;                   
		this.bottomLine = prodStub.bottomLine;             
		this.description = prodStub.description;            
		this.dontBuyType = prodStub.dontBuyType;            
		this.overallScoreMax = prodStub.overallScoreMax;
		this.overallScoreMin = prodStub.overallScoreMin;
		this.overallScore = prodStub.overallScore;   
		if(prodStub.price != null)
		{
			this.price = prodStub.price.value;
		}
		this.isRecommended = prodStub.isRecommended; 
		this.isBestSeller = prodStub.isBestSeller;  
		this.isTested = prodStub.isTested;      
		this.isBestBuy = prodStub.isBestBuy;
		
		// Calculate derived fields
		this.categoryId = prodStub.category.id;
		this.brandId = (prodStub.brand != null)? prodStub.brand.id : null;
		this.brandName = (prodStub.brand != null)? prodStub.brand.displayName : null;
		
		this.specs = new HashMap<String, Spec>();
		if(prodStub.specs != null)
		{
			for(SpecStub spec : prodStub.specs)
			{
				this.specs.put(spec.attributeId, new Spec(spec));
			}
		}
		
		this.numRatings = 0;
		this.ratings = new HashMap<String, Rating>();
		if(prodStub.ratings != null)
		{
			for(RatingStub rating : prodStub.ratings)
			{
				this.ratings.put(rating.attributeId, new Rating(rating));
				this.numRatings++;
			}
		}
	}
	
	void setCategory(Category pCategory)
	{
		category = pCategory;
	}
	
	/**
	 * @return The category ID.
	 */
	public String getCategoryId() 
	{ return categoryId; }
	
	/**
	 * @return The number of ratings.
	 */
	public int getNumRatings() 
	{ return numRatings; }

	/**
	 * @return The product ID.
	 */
	public String getId() 
	{ return id; }

	/**
	 * @return The display name of the product.
	 */
	public String getName() 
	{ return displayName; }
	
	public String getReview() {
		return review;
	}

	public String getHighs() {
		return highs;
	}

	public String getLows() {
		return lows;
	}

	public String getBottomLine() {
		return bottomLine;
	}

	public String getDescription() {
		return description;
	}

	public String getDontBuyType() {
		return dontBuyType;
	}
{'fraction_non_alphanumeric': 0.09130864740138446, 'fraction_numerical': 0.002197560707614548, 'mean_word_length': 3.2732394366197184, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5006206', 'n_tokens_mistral': 3069, 'n_tokens_neox': 2841, 'n_words': 755}