Beispiel #1
0
def getques():
	try:
		ques=sys.argv[1]
		worder=Worder()
		stems=[]
		named_ent=worder.named_entities(ques)
		print named_ent
		entities=re.findall(r'\s(.*?)/NN',str(named_ent)) #regex spliting about NN
		entities+=re.findall(r'\s(.*?)/VB',str(named_ent))
		print "entities are : "
		print(entities)
		for entity in entities: # for loop for finding the stems
			stems.append(worder.stemmer(entity))
		print "stems are :"
		print stems
		descriptives= ','.join(re.findall(r'\s(.*?)/WP',str(named_ent)))
		print "descriptive or type of question is : %s" %(descriptives)
		print "searching using stems........"
		search=''.join(entities).strip()
		print search
		def keyword():
			return search
		subprocess_cmd('python src/main.py'+ " " +search+',')
		print 'python src/main.py'+ " " +search+','		
	except Exception ,e:
		print(str(e))
		print "traceback: error in getques() of question.py"
Beispiel #2
0
def split_by_lines():
	subprocess_cmd("cat output/extract.txt | tr -d ',' |tr '\n' ' ' | tr '.?!' '\n' > output/lines.txt")
	line=file("output/lines.txt","rb").read()
        lines=re.findall(r'(.*?)\n',line)
        keywords=re.findall(r'(.*?),',keyword)
        answer=[]
#	for l in range(2,len(lines)):
#		for keyword in keywords:
#			if keyword.isdigit():
#				breakpoint=l;
#			else if 
        for l in range(1,len(lines)):
		for keyword in keywords:
			if keyword in lines[l]:
	#			print "success"
			        answer.append(lines[l])
				
				for i in range(1,9):
					if l+i < len(lines):
						answer.append(lines[l+i])
					else: 
						pass
                               
	if not answer:
		for l in range(1,len(lines)):
			answer.append(lines[l])
        print '.\n'.join(answer)
Beispiel #3
0
def split_by_lines(keywords):
	print "in"
	subprocess_cmd("cat extract.txt | tr -d ',' |tr '\n' ' ' | tr '.?!' '\n' > lines.txt")
	line=file("lines.txt","rb").read()
        lines=re.findall(r'(.*?)\n',line)
        keys=re.findall(r'(.*?),',keywords)
        answer=[]
        for l in range(1,len(lines)):
		for key in keys:
			if key in lines[l]:
			        answer.append(lines[l])
				for i in range(1,9):
					if l+i < len(lines):
						answer.append(lines[l+i])
					else: 
						pass
      	if not answer:
		for l in range(1,len(lines)):
			answer.append(lines[l])
        print '.\n'.join(answer)