query_vector_converter.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:tf-sparql 作者: derdav3 项目源码 文件源码
def jena_graph(java_file, args):
    '''
    Starts Main.java in the same folder and converts it into a query tree, then into a nested list
    '''
    graph = ''
    #Makes the call to start Main.java - gets output of file via System.out.println(string)
    cmd = ["java", "-cp", "/Users/david/libs/jena/lib/*:.", java_file, args]
    proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
    stdout, stderr = proc.communicate()

    for line in stdout:
        graph += line

    try:
        res_graph = pp.nestedExpr(opener='(', closer=')').parseString(graph)
        res_graph = res_graph.asList()
    except:
        print "pyparse err", graph, args
        res_graph = -1
    return res_graph
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号