def printAgeEmbededJson(): for line in sys.stdin: line = line.rstrip('\n') line = getJsonResponse(line) if not line: continue dom = json.loads(line) text = dom['text'] text = rtStrip(text) text = quoteStrip(text) text = spamStrip(text); matchObj = yearsFilter(text) if matchObj: age = 100 ageString = matchObj.age.strip(' ') # check normal digit dmatch = re.match(r'^\d+$', ageString) if dmatch: age = int(dmatch.group()) # check pi-multiplied dmatch = re.match(r'^(\d*\.\d+)pi$', ageString, re.I) if dmatch: age = int(float(dmatch.group(1)) * 3.14) # now see the age and increase the count if age < 65 and age > 0: dom['user']['age'] = str(age) print json.dumps(dom)
def filterTest(): for line in sys.stdin: line = line.rstrip('\n') line = getJsonResponse(line) if line: print line