How do I find similarities 2 texts/arrays?

0 favourites
  • 5 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • 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 .

    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!

  • 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

    result --

  • Thanks paladin it works perfectly!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • Thanks oosyrag,

    I'll be looking into that aswell! I haven't done anything with the dictionary object yet..

    Thanks again!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)