Example #1
1
def main(params):

    chatnoir = Chatnoir()

    lInfo("ok")
    jPrint(chatnoir.get_by_query("star trek"))
    jPrint(chatnoir.get_document_by_id("clueweb09-en0011-25-35348"))
    jPrint(chatnoir.get_snippet("clueweb09-en0011-25-35348", "star trek"))
Example #2
0
def main(params):

    wikidata = Wikidata()

    lInfo("ok")
    entity = "bathroom".lower()
    query = "choose bathroom".lower()

    res = wikidata.get_by_query(entity)

    lInfo(json.dumps(res, indent=4, sort_keys=True))

    related_terms = {entity: 1, query: 1}

    for x in res["search"]:
        k = x["label"].lower()
        related_terms[k] = 1
        #print([x["label"],x.get("description", ""), x["id"]])

    print(len(related_terms))

    for k in sorted(related_terms.keys()):
        print("{} : {}".format(k, related_terms[k]))

    print(json.dumps(wikidata.get_related(entity), indent=4, sort_keys=True))

    query = "solar power home"
    entity = "solar power"
    mid = "/m/05t0ydv"
    print((query, entity, mid))
    print(
        json.dumps(wikidata.get_related(query, entity, mid),
                   indent=4,
                   sort_keys=True))
Example #3
0
def main(params):

    wikidata = Wikidata()

    lInfo("ok")
    entity = "bathroom".lower()
    query = "choose bathroom".lower()

    res = wikidata.get_by_query(entity)

    lInfo(json.dumps(res, indent=4, sort_keys=True))

    related_terms = {entity: 1, query: 1}

    for x in res["search"]:
        k = x["label"].lower()
        related_terms[k] = 1
        #print([x["label"],x.get("description", ""), x["id"]])

    print(len(related_terms))

    for k in sorted(related_terms.keys()):
        print("{} : {}".format(k, related_terms[k]))

    print(json.dumps(wikidata.get_related(entity), indent=4, sort_keys=True))

    query = "solar power home"
    entity = "solar power"
    mid = "/m/05t0ydv"
    print((query, entity, mid))
    print(json.dumps(wikidata.get_related(query, entity, mid), indent=4, sort_keys=True))
Example #4
0
def main(params):

    chatnoir = Chatnoir()

    lInfo("ok")
    jPrint(chatnoir.get_by_query("star trek"))
    jPrint(chatnoir.get_document_by_id("clueweb09-en0011-25-35348"))
    jPrint(chatnoir.get_snippet("clueweb09-en0011-25-35348", "star trek"))
Example #5
0
def main(params):

    chatnoir2 = Chatnoir2()

    lInfo("ok")
    lInfo(
        json.dumps(chatnoir2.get_by_query("star trek"),
                   indent=4,
                   sort_keys=True))
Example #6
0
def main(params):

    netspeak = Netspeak()

    lInfo("ok")
    entity = "bathroom".lower()
    query = "choose bathroom".lower()

    res = netspeak.get_related(query)
    lInfo(json.dumps(res, indent=4, sort_keys=True))
Example #7
0
def main(params):

    query_segmentation = QuerySegmentation()

    lInfo("ok")
    entity = "bathroom".lower()
    query = "choose bathroom".lower()

    res = query_segmentation.get_by_query(query)

    lInfo(json.dumps(res, indent=4, sort_keys=True))

    print(res["hyb-a"])
Example #8
0
def main(params):

    query_segmentation = QuerySegmentation()

    lInfo("ok")
    entity = "bathroom".lower()
    query = "choose bathroom".lower()

    res = query_segmentation.get_by_query(query)

    lInfo(json.dumps(res, indent=4, sort_keys=True))

    print(res["hyb-a"])
Example #9
0
def main(params):
    parser = argparse.ArgumentParser(
        description=
        'google_api - send search requests to google and return resulting urls',
        epilog="stg7 2015")

    parser.add_argument('query', type=str, nargs='+', help='query')
    argsdict = vars(parser.parse_args())

    query = " ".join(argsdict["query"])
    lInfo(query)

    google = Google()
    results = google.get_by_query(query, 15)

    jPrint(results)

    print("\n\n")
    query = "solar power home"
    entity = "solar power"
    mid = "/m/05t0ydv"

    jPrint(google.get_related(query, entity, mid))
Example #10
0
def main(params):

    freebase = Freebase()

    lInfo("ok")
    lInfo(
        json.dumps(freebase.get_by_query("star trek"),
                   indent=4,
                   sort_keys=True))
    lInfo("...")
    lInfo(
        json.dumps(freebase.get_by_mid("/m/01j2bj"), indent=4, sort_keys=True))

    midresult = freebase.get_by_mid("/m/0jpmt")
    lInfo(json.dumps(midresult, indent=4, sort_keys=True))

    names = [x["name"] for x in midresult["result"]]
    lInfo(names)

    query = "solar power home"
    entity = "solar power"
    mid = "/m/05t0ydv"

    result = freebase.get_related(query, entity=entity, mid=mid)
    lInfo(json.dumps(result, indent=4, sort_keys=True))
Example #11
0
def main(params):


    freebase = Freebase()

    lInfo("ok")
    lInfo(json.dumps(freebase.get_by_query("star trek"), indent=4, sort_keys=True))
    lInfo("...")
    lInfo(json.dumps(freebase.get_by_mid("/m/01j2bj"), indent=4, sort_keys=True))

    midresult = freebase.get_by_mid("/m/0jpmt")
    lInfo(json.dumps(midresult, indent=4, sort_keys=True))

    names = [x["name"] for x in midresult["result"]]
    lInfo(names)

    query = "solar power home"
    entity = "solar power"
    mid = "/m/05t0ydv"

    result = freebase.get_related(query, entity=entity, mid=mid)
    lInfo(json.dumps(result, indent=4, sort_keys=True))
Example #12
0
def main(params):

    chatnoir2 = Chatnoir2()

    lInfo("ok")
    lInfo(json.dumps(chatnoir2.get_by_query("star trek"), indent=4, sort_keys=True))