Skip to content
Advertisement

matching names across multiple lists

the following code is what I’ve tried to do so far:

import json

uids = {'483775843796': '"jared trav"','483843796': '"azu jared"', '483843996': '"hello azu"', '44384376': '"bitten virgo"', '48384326': '"bitten hello"', '61063868': '"charm feline voxela derp virgo"', '11136664': '"jessica"', '11485423': '"yukkixxtsuki"', '10401438': '"howen"', '29176667': '"zaku ramba char"', '36976082': '"bulma zelda dame prince"', '99661300': '"voxela"', '76923817': '"juniperrose"', '16179876': '"gnollfighter"', '45012369': '"pianist fuzz t travis blunt trav ttttttttttttttttttyt whole ryann lol tiper cuz"', '62797501': '"asriel"', '73647929': '"voxela"', '95019796': '"dao daoisms"', '70094978': '"mort"', '16233382': '"purrs"', '89270209': '"apocalevie waify"', '42873540': '"tear slash peaches attitude maso lyra juvia innocent"', '61284894': '"pup"', '68487075': '"ninja"', '66451758': '"az"', '23492247': '"vegeta"', '77980169': '"virus"'}

def _whois(string):
    a = []
    for i in uids:
        i = json.loads(uids[i])
        i = i.split()
        if string in i:
            a += i
    for i in uids:
        i = json.loads(uids[i])
        i = i.split()
        if bool(set(i) & set(a)) == True:
            a += i
    return list(set(a))

def whois(string):
    a = []
    ret = _whois(string)
    for i in ret:
        a += _whois(i)
    return list(set(a))

print(whois("charm"))

I am trying to match a search term with accounts that share an id with the term in it, and then match each of those other accounts that are with the id to other accounts on other ids and so on and basically see all of the linked accounts that start from a single term.

For example, if I searched “charm” it would return: “charm feline voxela derp virgo bitten hello” from the example uids above.

After a certain way down the line of connected accounts it stops matching. How would I successfully do this so that it matches all accounts potentially infinitely?

Advertisement

Answer

i think i got it to work:

import json

terms = {'4837759863453450996': '"mamma riyoken"','4833480984509580996': '"mamma heika"','483775980980996': '"nemo heika"','4867568843796': '"control nemo"','4956775843796': '"t control"','483775843796': '"jared trav"','483843796': '"azu jared"', '483843996': '"hello azu"', '44384376': '"bitten virgo"', '48384326': '"bitten hello"', '61063868': '"charm feline voxela derp virgo"', '11136664': '"jessica"', '11485423': '"yukkixxtsuki"', '10401438': '"howen"', '29176667': '"zaku ramba char"', '36976082': '"bulma zelda dame prince"', '99661300': '"voxela"', '76923817': '"juniperrose"', '16179876': '"gnollfighter"', '45012369': '"pianist fuzz t travis blunt trav ttttttttttttttttttyt whole ryann lol tiper cuz"', '62797501': '"asriel"', '73647929': '"voxela"', '95019796': '"dao daoisms"', '70094978': '"mort"', '16233382': '"purrs"', '89270209': '"apocalevie waify"', '42873540': '"tear slash peaches attitude maso lyra juvia innocent"', '61284894': '"pup"', '68487075': '"ninja"', '66451758': '"az"', '23492247': '"vegeta"', '77980169': '"virus"'}

def _search(string):
    a = []
    for i in terms:
        i = json.loads(terms[i])
        i = i.split()
        if string in i:
            a += i
    return list(set(a))

def search(string):
    a = []
    a.append(string)
    while True:
        l = len(a)
        for n in a:
            a += _search(n)
            a = list(set(a))
        if l == len(a):
            break
    return a
    
            
print(search("charm"))
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement