Ismael Gandarillas
Ismael Gandarillas

Reputation: 111

Compare two items based on their names

I'm programming a bot in Java with HtmlUnit that gets data (name and price) from two different e-commerce sites, A and B.

Once I have gathered all items in a csv file (name ; price) i try to compare them to know which items are the same.

Rarely the name of an A item is equals to name of a B item, but often they have some similarities such as model name or brand name.

Someone have an idea or knows a mechanism to compare this items and know if they are the same item?

Edit:

At least there are 82,000 itemA and 2000 itemB, and I need a injective function that assigns it.

itemA is composed of: brand name and model name. (Structure -> Good).

itemB is composed of: Descriptive text with the brand name and model name inside, without any structure.

Upvotes: 1

Views: 413

Answers (1)

user4608261
user4608261

Reputation:

Why don't you use String equals() Method. This method compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object. Below is an example of working code:

  String Str1 = new String("This is really not immutable!!");
  String Str2 = Str1;
  String Str3 = new String("This is really not immutable!!");
  boolean retVal;

  retVal = Str1.equals( Str2 );
  System.out.println("Returned Value = " + retVal );

  retVal = Str1.equals( Str3 );
  System.out.println("Returned Value = " + retVal ); 

This method returns true if the String are equal; false otherwise.

Upvotes: 1

Related Questions