示例#1
0
    text = dp.read()
items = text.split('\n==========\n')

nq = 0
resultdata = {}
alltime = Timestamp()

for item in items:
    if item == '': continue
    (mqlbody, qinfo, idstr) = item.split('\n----------\n')
    ids = idstr.split(',')
    (qid, qname) = qinfo.split('..........')
    nq += 1
    alltime.msg('{:>3} qid={:>3} {:<30} ...'.format(nq, qid, qname[0:29]), newline=False)
    thistime = Timestamp()
    (good, nresults, xmonads) = mql('4', mqlbody)
    if good:
        nresultmonads = count_monads(xmonads)
        for id in ids:
            resultdata[id] = (nresults, nresultmonads)
        thistime.msg('OK - {} - {}'.format(nresults, nresultmonads))
    else:
        sys.stdout.write('ERROR\n')
alltime.msg('Done')


with open(data_outpath, 'w') as dp:
    for id in sorted(resultdata):
        dp.write(u'{}\t{}\t{}\n'.format(id, resultdata[id][0], resultdata[id][1]))

print 'Written data to {}'.format(data_outpath)
示例#2
0
文件: test.py 项目: ETCBC/shebanq
from mql import mql

q = '''
Select all objects where 
[sentence
  [word focus lex='JHWH/']
  [word focus lex='>LHJM/']
]
GO
'''

msgs = []

print(mql('4b', q))