String Searching algorithm

A title for a movie can be ambiguous. (Eg. The Lord of the Rings, Lord of the Rings, Lord of the Rings, The)
There exists a database entry that has a list of movie titles mapped to a unique identifier.

I am trying to write a method that takes a String title input and returns the unique identifier mapped to it after having resolved any ambiguity.(Is is a sequel? A remake?)

What is a good data structure to be used here?

Your question is a little unclear as the title asks for an algorithm, but you also ask for a data structure. I will describe what I did with a similar issue, dealing with music.

The way I approached it was with a series of string transformations that produced a string with as much ambiguity removed as possible.

A few of the rules:

  • Remove all whitespace
  • Change all non-ASCII letters to ASCII equivalents. (ö -> o)
  • Change everything to uppercase
  • If a comma is encountered, swap the right side of the common with the left
  • Remove common words like “the”, “of”, etc.
  • Change Roman numerals to Arabic (“VII” -> 7)

So I’d end up with:

Blue Öyster Cult -> BLUEOYSTERCULT
Amos, Tori -> TORIAMOS
The Red Hot Chili Peppers -> REDHOTCHILIPEPPERS

I then used that for all comparisons, though it was never exposed to the user. In my case, I just used this as the identifier.

The rules were necessarily a bunch of heuristics developed by experimenting with real CDDB data. It obviously wasn’t guaranteed to be foolproof, but it wasn’t that hard to find a set that worked most of the time.

Your issue isn’t quite the same. Remakes will be a problem because your titles will match. That might be partially solvable by looking for dates in the title (“Total Recall (2013)”) but I suspect that data will often be missing.

4

I would begin by sanitizing the input data much like @Steven Burnap and then calculate the Levenshtein distance between the input and all known movie titles. Return the top couple results. Since there’s likely to be a high degree of variation between your users’ input and your list of known movie titles, an exact string search algorithm isn’t a good fit.

You’ll have to experiment to find the most accurate and quickest fuzzy search algorithm for your use case, and you’ll have to decide if it’s faster to perform the calculation in the DB or on an app server. It just comes down to your app architecture.

edit: When you’re dealing with sequels, I would treat all titles within a series as having an equal weight, and then choose the most appropriate answer based upon some external factor. For your software’s initial release, maybe just sort by movie release date. For a second release, poll an external API to find the most buzzworthy title. For a third release, perhaps gather some user metrics to find the most relevant result (for instance, if the user regularly prefers sequels over originals, give the sequel a higher score).

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

String Searching algorithm

A title for a movie can be ambiguous. (Eg. The Lord of the Rings, Lord of the Rings, Lord of the Rings, The)
There exists a database entry that has a list of movie titles mapped to a unique identifier.

I am trying to write a method that takes a String title input and returns the unique identifier mapped to it after having resolved any ambiguity.(Is is a sequel? A remake?)

What is a good data structure to be used here?

Your question is a little unclear as the title asks for an algorithm, but you also ask for a data structure. I will describe what I did with a similar issue, dealing with music.

The way I approached it was with a series of string transformations that produced a string with as much ambiguity removed as possible.

A few of the rules:

  • Remove all whitespace
  • Change all non-ASCII letters to ASCII equivalents. (ö -> o)
  • Change everything to uppercase
  • If a comma is encountered, swap the right side of the common with the left
  • Remove common words like “the”, “of”, etc.
  • Change Roman numerals to Arabic (“VII” -> 7)

So I’d end up with:

Blue Öyster Cult -> BLUEOYSTERCULT
Amos, Tori -> TORIAMOS
The Red Hot Chili Peppers -> REDHOTCHILIPEPPERS

I then used that for all comparisons, though it was never exposed to the user. In my case, I just used this as the identifier.

The rules were necessarily a bunch of heuristics developed by experimenting with real CDDB data. It obviously wasn’t guaranteed to be foolproof, but it wasn’t that hard to find a set that worked most of the time.

Your issue isn’t quite the same. Remakes will be a problem because your titles will match. That might be partially solvable by looking for dates in the title (“Total Recall (2013)”) but I suspect that data will often be missing.

4

I would begin by sanitizing the input data much like @Steven Burnap and then calculate the Levenshtein distance between the input and all known movie titles. Return the top couple results. Since there’s likely to be a high degree of variation between your users’ input and your list of known movie titles, an exact string search algorithm isn’t a good fit.

You’ll have to experiment to find the most accurate and quickest fuzzy search algorithm for your use case, and you’ll have to decide if it’s faster to perform the calculation in the DB or on an app server. It just comes down to your app architecture.

edit: When you’re dealing with sequels, I would treat all titles within a series as having an equal weight, and then choose the most appropriate answer based upon some external factor. For your software’s initial release, maybe just sort by movie release date. For a second release, poll an external API to find the most buzzworthy title. For a third release, perhaps gather some user metrics to find the most relevant result (for instance, if the user regularly prefers sequels over originals, give the sequel a higher score).

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật