0
$\begingroup$

Consider the following 3 strings:

1tb hdd 256gb ssd
hdd 256gb
1tb hdd

If you know, that all of these strings are part of a product title, specifically part of the title of a Laptop product, a human can easily read these out, and understand that the specific laptop for which the respective string is part of has either hdd/ssd disk in it, and if it has, he can also decide the capacity of the said disk.

Is there any way to programatically make the same assumption correctly?

I am trying to parse the attributes of some products from their titles, and this exact problem arose: some titles have the ordering of {disktype} {capacity}, some have the ordering of {capacity} {disktype}, and I can't figure out a way to correctly identify the order, so that I can correctly parse the attribute and the data. In some cases, the titles contain , characters, which is very helpful in this situation, but there are a few cases where there are no other delimiters except \s characters.

To make things worse, some product titles only contain the following structure: 1tb ssd 512gb. Based on the human understanding, and the context of the above string, for a human, it is still decidable which type of hard disk the laptop contains, and what capacity does it have, but can a computer do this programaticaly in a safe way also?

$\endgroup$
5
  • 1
    $\begingroup$ Is it straightforward what to do for products that have only a hdd or a ssd but not both? If not, what are the difficult cases? I see only one example, and it's not intuitive to me where that comes from (why would someone write that in a title? it seems ambiguous) or what the correct interpretation of it should be. It might be useful to separate the case of "only hdd"/"only ssd" from handling products that have both a ssd and hdd. $\endgroup$
    – D.W.
    May 18, 2021 at 6:04
  • $\begingroup$ @D.W. it is indeed ambigous, but those titles come from webshops around the world, and each to it's own - I am in no control unfortunately, on how they title their products. Basically, I can't say they are at fault in this at all, as I said it earlier, as a human, for me (with some basic knowledge of the topic) it easy to decide what is what in the title, and those titles were written for human consumption. Separation is a good preprocessing idea, which would help in some cases, but it still wouldn't solve the complete problem - however, I will definitely implement that as it will help $\endgroup$ May 18, 2021 at 6:14
  • $\begingroup$ @D.W. however, separation will also fail on the example I have given in the last paragraph 1tb ssd 512gb where the larger capacity is implied to be the hdd in the product - for that, my separation algorithm will imply that the product only contains ssd in it, and will still fail $\endgroup$ May 18, 2021 at 6:15
  • 1
    $\begingroup$ Computers aren't magic. If it's ambiguous, then ain't no algorithm gonna fix that. I suggest you spend some time collecting examples of products that have only a hdd (or only a ssd) and where it is unambiguous for a human what the correct answer is and where a basic algorithm can't get the right answer. Then, use that to see if there are some simple rules that can handle those cases, and edit the question to share your work and those examples. That will help you figure out whether you can solve an important special case. Basically, I am recommending you take a data-driven approach. $\endgroup$
    – D.W.
    May 18, 2021 at 6:19
  • $\begingroup$ I know that they aren't:)) what I was asking for basically, if any one knows of an implementable solution, that I've missed (because of my limited logic for example), that could be used in this situation:) like your idea with separation, which would work in some cases, but would fail in others $\endgroup$ May 18, 2021 at 6:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.