How do I find similarities 2 texts/arrays?

Get help using Construct 2

Post » Sun Sep 25, 2016 3:48 pm

Hi,
In my latest App I have 2 arrays and I would like to pick an index of the first array, which contains similar words like any index of the first array.
The goal is to pick the index of the first array, that contains words which the user has put in his "favourites" (second array).
For example:

First Array:
1. Dog Flower Cat
2. The cool cat

Second Array:
1. ??? ??? ???
2. Flower Cat Smiley

In this case, the first index of the first array contains two matching words with the second index of the second array so the program should pick the first index of the second array.

Hopefully this explains my problem a little better :D .
I just tried to do it with many loops but I actually lost the overview :/ .
Does anyone know of an easy way to do it?
Any help is appreciated!
Thanks! :)
B
5
S
3
Posts: 194
Reputation: 1,065

Post » Sun Sep 25, 2016 5:35 pm

It would be easiest to have 2 dimensional arrays, where your x axis is each list of words and your y axis is the words themselves. If this comes from a text box from the user's input, you will have to parse these using the tokencount and tokenat expressions. I have put together an example app for you, which works according to your explanation however -- https://mega.nz/#!CtNDFDjb!FyfDEm50qRNCSg-dyf1_OqFi3cg4SNBlYIFoiymg4yg

Image

result --
Image
B
9
S
1
Posts: 12
Reputation: 448

Post » Sun Sep 25, 2016 5:52 pm

Thanks @paladin it works perfectly! :)
B
5
S
3
Posts: 194
Reputation: 1,065

Post » Wed Sep 28, 2016 1:46 am

Depending on your data structure, the dictionary object may be worth looking in to as well. You would have an instance of a dictionary for each set of words, and you would be able to use the "For Each Key" and "Has key" conditions to check for matches.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Wed Sep 28, 2016 9:12 pm

Thanks @oosyrag,
I'll be looking into that aswell! I haven't done anything with the dictionary object yet..
Thanks again! :)
B
5
S
3
Posts: 194
Reputation: 1,065


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests