Ejemplo n.º 1
0
def findTimes(rule, fuzzy = True):
    users = set()
    times = list()
    for fn in jsonFiles:
        rooms = json.loads(open(fn).read())
        for room in rooms:
            for u in room['users']:
                if match(u, rule, fuzzy):
                    times.append(fn)
                    users.add((u['name'] + '#' + u.get('tripcode', '')))
    times.sort()
    return times, users
Ejemplo n.º 2
0
def main():
    os.environ[
        "GOOGLE_APPLICATION_CREDENTIALS"] = "./resources/credentials/e3682f457e02.json"
    os.system("cls")
    project_id = "recruitertest-dd3ab"
    session_id = str(uuid.uuid4().hex[:12])
    language_code = "en-US"
    input_file_path = "./resources/audio/subject_input.wav"

    # [START DIALOG]
    complete_transcript = [[], []]

    # [QUICK DIALOG]
    # complete_transcript = detect_intent_texts(project_id, session_id, [
    #     "DEMO_START", "Diana Moon", "18", "Adaptable , ambitious, clever and blunt", "I have a bachelor in mathematics",
    #     "I have worked for Google as a data scientist of the past 3 years", "I am good at analysis and computers", "My communication is not great", "40 hours", "No"], language_code)

    # [NORMAL DIALOG]
    detect_intent_texts(project_id, session_id, ["DEMO_START"], language_code)
    while True:
        # text_input = input("Text input: ")
        # partial_transcript = detect_intent_texts(project_id, session_id, [
        #     text_input], language_code)

        audio.record(input_file_path)
        partial_transcript = detect_intent_audio(project_id, session_id,
                                                 input_file_path,
                                                 language_code)

        # audio.record(input_file_path)
        # partial_transcript = detect_intent_stream(project_id, session_id,
        #                                           input_file_path, language_code)

        complete_transcript[0] = complete_transcript[0] + partial_transcript[0]
        complete_transcript[1] = complete_transcript[1] + partial_transcript[1]

        if poke(project_id, session_id, language_code):
            break

    # [END DIALOG]

    # [DATA]
    subject_info = get_subject_info(project_id, session_id, language_code)
    clean_subject_info = data.clean(subject_info)
    match_scores = data.match(subject_info)

    report.create(clean_subject_info, match_scores, complete_transcript,
                  session_id)
Ejemplo n.º 3
0
def findFriends(rule, fuzzy=True):
    friends = set()
    fnames = set()
    fcodes = set()
    for filename in jsonFiles:
        rooms = json.loads(open(filename).read())
        for room in rooms:
            for user in room['users']:
                if match(user, rule, fuzzy):
                    for u in room['users']:
                        fn, fc = u['name'], u.get('tripcode', '')
                        fnames.add(fn)
                        if fc: fcodes.add(fc)
                    friends.update([(u['name'], u.get('tripcode', ''))
                                    for u in room['users']])
    return friends, fnames, fcodes
Ejemplo n.º 4
0
def findFriends(rule, fuzzy=True):
    friends = set()
    fnames = set()
    fcodes = set()
    roomHost = dict()
    for filename in jsonFiles:
        rooms = json.loads(open(filename).read())
        for room in rooms:
            if room['name'] not in roomHost:
                d = roomHost.setdefault(room['name'], dict())
                d[room['host']['name']] = d.get(room['host']['name'], 0) + 1
            for user in room['users']:
                if match(user, rule, fuzzy):
                    for u in room['users']:
                        fn, fc = u['name'], u.get('tripcode', '')
                        fnames.add(fn)
                        if fc: fcodes.add(fc)
                    friends.update([(u['name'], u.get('tripcode', ''))
                                    for u in room['users']])
    for roomName in roomHost:
        host = keyOfMaxVal(roomHost[roomName])
        roomHost[roomName] = host
    return friends, fnames, fcodes, roomHost
Ejemplo n.º 5
0
import os, sys, json
from pprint import pprint
from data import jsonFiles, match

if len(sys.argv) <= 1:
    print('Usage: python {} [name | "#tripcode"]'.format(sys.argv[0]))
    print('Example: python {} "#.*cat"'.format(sys.argv[0]))
    print('Example: python {} lambda'.format(sys.argv[0]))
    exit(0)

friends = set()
for fn in jsonFiles:
    rooms = json.loads(open(fn).read())
    for room in rooms:
        for u in room['users']:
            for p in sys.argv[1:]:
                if match(u, p):
                    friends.update([(u['name'] + '#' + u.get('tripcode', ''))
                                    for u in room['users']])
pprint(friends)
Ejemplo n.º 6
0
import os, sys, json
from pprint import pprint
from data import match, jsonFiles

if len(sys.argv) <= 2:
    print('Usage: python {} [name | "#tripcode"] [name | "#tripcode"]'.format(
        sys.argv[0]))
    print('Example: python {} "#.*cat" "lambda"'.format(sys.argv[0]))
    print('Example: python {} lambda'.format(sys.argv[0]))
    exit(0)

manA, manB = sys.argv[1:]

record = []
for fn in jsonFiles:
    rooms = json.loads(open(fn).read())
    for room in rooms:
        cnt, us = 0, []
        for u in room['users']:
            if match(u, manA) or match(u, manB):
                us.append(u['name'] + '#' + u.get('tripcode', ''))
                cnt += 1
        if cnt >= 2:
            record.append((os.path.splitext(fn)[0], us))

record.sort()

for r in record:
    pprint(r)