Hello everyone.
It took the search algorithm in the inverted index, it looks like this:
Moscow 1 2 4
Beijing 1 3 6 9
London 3 8 9
That is, when requesting Moscow Beijing, the search should produce the number one. I can’t think of such an algorithm in any way, I’ve already processed the string value of strings too (digits after names). All this is in the Map structure as a pair of key - value (String - int [])
Names are not necessarily three of them can be more .. Yes, and tsiferok also a different number
UPD!
I will explain again, we have a file with the following lines:
- Moscow 1 2 4
- Beijing 1 3 6 9
- London 3 8 9
Create a Map, the key in it will be words, and the values of the digit, that is, <String, int []> There is a query (String) - Moscow Beijing, divide the string into spaces, look for matches in the Map, f with the key and print the values, that is for the line Moscow Beijing at will be the conclusion: [1,2,4] [1,3,6,9]
The very highlight is that here in these values it is necessary to find the same elements, we see - 1, this will be the output of the program)
So far I have stopped at this (Where Slova is an array of words, and Base, but the Map structure with a key and a value):
if (Slova[i].equalsIgnoreCase(Basa.getKey())) { System.out.println(Basa.getValue()); } UPD2!
2) in these data (arrays) to find the elements that match in values. So, to find identical numbers.
Thank you in advance for the description of such an algorithm!