<commit_before>#!/usr/bin/python

#So we load in the terms that allow the API implementation to happen for now.
execfile("APIimplementation.py")

import cgitb
cgitb.enable()

def headers(method):
    if method!="return_tsv":
        print "Content-type: text/html\n"
    elif method=="return_tsv":
        print "Content-type: text; charset=utf-8"
        print "Content-Disposition: filename=Bookworm-data.txt"
        print "Pragma: no-cache"
        print "Expires: 0\n"
        
outfile = open("/var/log/presidio/log.txt",'a')
form = cgi.FieldStorage()

if len(form) > 0: #(Use CGI input if it's there:)
    JSONinput = form["queryTerms"].value
    outfile.write(JSONinput)
    outfile.write("\n")
    data = json.loads(JSONinput)
    #For back-compatability, "method" can be defined in the json or as a separate part of the post.
    #Using the form-posting way of returning 'method' is deprecated.
    try:
        method = form["method"].value
        data['method'] = method
    except:
        try:
            method = data['method']
        except:
            raise
            pass
    headers(method)

    #if somewhere else has already set a privileges level, then you can get higher ones here.
    try:
        privileges = priorPrivileges
    except:
        privileges = "basic"


    if privileges == "minimal":
        if len (data['groupings']) > 1:
            print "Too many groupings: please request an API key to complete this operation"
        for group in data['groupings']:
            pass<commit_msg>Searches work with empty word terms<commit_after>#!/usr/local/bin/python

#So we load in the terms that allow the API implementation to happen for now.
execfile("APIimplementation.py")

import cgitb
cgitb.enable()

def headers(method):
    if method!="return_tsv":
        print "Content-type: text/html\n"
    elif method=="return_tsv":
        print "Content-type: text; charset=utf-8"
        print "Content-Disposition: filename=Bookworm-data.txt"
        print "Pragma: no-cache"
        print "Expires: 0\n"
        
outfile = open("/var/log/presidio/log.txt",'a')
form = cgi.FieldStorage()

if len(form) > 0: #(Use CGI input if it's there:)
    JSONinput = form["queryTerms"].value
    outfile.write(JSONinput)
    outfile.write("\n")
    output = open("/tmp/err",'w'); output.write(json.__file__)
    data = json.loads(JSONinput)
    #For back-compatability, "method" can be defined in the json or as a separate part of the post.
    #Using the form-posting way of returning 'method' is deprecated.
    try:
        method = form["method"].value
        data['method'] = method
    except:
        try:
            method = data['method']
        except:
            raise
            pass
    headers(method)

    #if somewhere else has already set a privileges level, then you can get higher ones here.
    try:
        privileges = priorPrivileges
    except:
        privileges = "basic"


    if privileges == "minimal":
        if len (data['groupings']) > 1:
            print "Too many groupings: please request an API key to complete this operation"
        for group in data['groupings']:
            pass
{'fraction_non_alphanumeric': 0.1109350237717908, 'fraction_numerical': 0.0025356576862123614, 'mean_word_length': 2.5822928490351873, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7077775', 'n_tokens_mistral': 959, 'n_tokens_neox': 932, 'n_words': 301}