# HG changeset patch # User casties # Date 1449781249 18000 # Node ID 2564732249b3ee02f42b488538c3e7c5d02f1f13 # Parent 5384b71df52a1e9288ce34b0df40b82d97c3b932 search for authors names uses normalization now. diff -r 5384b71df52a -r 2564732249b3 ismi-python-neo4jrestclient/ismi-vis.py --- a/ismi-python-neo4jrestclient/ismi-vis.py Thu Dec 10 07:26:40 2015 -0500 +++ b/ismi-python-neo4jrestclient/ismi-vis.py Thu Dec 10 16:00:49 2015 -0500 @@ -1,5 +1,6 @@ #!/usr/bin/env python -from json import dumps +from json import dumps, loads +import urllib.request from flask import Flask, Response, request, send_from_directory @@ -8,11 +9,18 @@ app = Flask(__name__, static_url_path='/static/') app.debug = True gdb = GraphDatabase("http://localhost:7474", username="neo4j", password="neo5j") +ismi_db_baseurl = "http://localhost:18080/ismi-richfaces/" + +def loadJSON(url): + #print("JSON loading %s"%url) + wsh=urllib.request.urlopen(url) + txt = wsh.read() + return loads(txt.decode("utf-8")) @app.route("/") def get_index(): - return app.send_static_file('commentaries.html') + return app.send_static_file('commentaries_authors2.html') @app.route("/commentaries.html") def get_commentaries(): @@ -148,15 +156,20 @@ def get_search(): try: q = request.args["q"] + norm_js = loadJSON(ismi_db_baseurl + "jsonInterface?method=normalize_string&type=arabic_translit&text=%s"%q) + nq = norm_js.get("normalized_text") except KeyError: return [] else: - query = ("MATCH (t:TEXT)-[:was_created_by]->(p:PERSON {ismi_id: {id}})" + #query = ("MATCH (t:TEXT)-[:was_created_by]->(p:PERSON {ismi_id: {id}})" + # " RETURN t,p,exists((t)-[:is_commentary_on]->()),exists(()-[:is_commentary_on]->(t))") + query = ("MATCH (t:TEXT)-[:was_created_by]->(p:PERSON)" + " WHERE p._n_label =~ {name}" " RETURN t,p,exists((t)-[:is_commentary_on]->()),exists(()-[:is_commentary_on]->(t))") results = gdb.query( query, returns=(Node,Node,bool,bool), - params={"id": int(q)} + params={"name": ".*%s.*"%nq.lower()} ) # {"name": "(?i).*" + q + ".*"} print("search for %s returned %s results"%(repr(q),len(results))) diff -r 5384b71df52a -r 2564732249b3 ismi-python-neo4jrestclient/static/commentaries_authors2.html --- a/ismi-python-neo4jrestclient/static/commentaries_authors2.html Thu Dec 10 07:26:40 2015 -0500 +++ b/ismi-python-neo4jrestclient/static/commentaries_authors2.html Thu Dec 10 16:00:49 2015 -0500 @@ -14,9 +14,9 @@