<commit_before>#opdracht 3x

import sys
from SPARQLWrapper import SPARQLWrapper, JSON

lidwoorden = ["de", "het", "een"]

def print_example_queries():
	print("Wat is de startdatum van de Olympische Spelen 2012?")
	print("Wat is de plaats van de Olympische Zomerspelen 2008?")
	print("Wat is de lengte van <NAME>?")
	print("Wie is de trainer van <NAME>?")

def create_and_fire_query(line):
	propX = find_prop(line)
	conceptY = find_concept(line)

def find_prop(line):
	line = line.split()
	if line[2] in lidwoorden:
		propX = line[3]
	else: 
		propX = line[2]

	return(propX)


def find_concept(line):
	#make concept usable to find in paircounts
	concept = line.split("van")[1]
	concept = concept.replace("?", "")
	concept = concept.replace("de", "")
	concept = concept.replace("het", "")
	concept = concept.strip()
	print(concept)

	for pair in open("pairCounts"):
		if str(concept) in pair:
			print(pair)
			pair = pair.split('\t')
			concept_Y = (pair[1])
			print(concept_Y)

#def create_and_fire_query(line):

def main(argv):
	print_example_queries()
	for line in sys.stdin:
		#haalt whitespace aan het einde van line weg
		line = line.rstrip()
		answer = create_and_fire_query(line)
		print(answer)

if __name__ == "__main__":
	main(sys.argv)

<commit_msg>Working finding concept and prop<commit_after>#opdracht 3x

import sys
from SPARQLWrapper import SPARQLWrapper, JSON

lidwoorden = ["de", "het", "een"]

def print_example_queries():
	print("Wat is de startdatum van de Olympische Spelen 2012?")
	print("Wat is de plaats van de Olympische Zomerspelen 2008?")
	print("Wat is de lengte van <NAME>?")
	print("Wie is de trainer van <NAME>?")

def create_and_fire_query(line):
	propX = find_prop(line)
	conceptY = find_concept(line)

	print(propX)
	print(conceptY)

def find_prop(line):
	line = line.split()
	if line[2] in lidwoorden:
		propX = line[3]
	else: 
		propX = line[2]

	return(propX)


def find_concept(line):
	#make concept usable to find in paircounts
	concept = line.split("van")[1]
	concept = concept.replace("?", "")
	concept = concept.replace("de", "")
	concept = concept.replace("het", "")
	concept = concept.strip()
	page = ["url", 0]

	for pair in open("pairCounts"):
		if str(concept) in pair:
			pair = pair.split('\t')
			if int(pair[2]) > page[1]:
				page[0] = pair[1]
				page[1] = int(pair[2])
	conceptY = page[0]
	return(conceptY)

#def create_and_fire_query(line):

def main(argv):
	print_example_queries()
	for line in sys.stdin:
		#haalt whitespace aan het einde van line weg
		line = line.rstrip()
		answer = create_and_fire_query(line)
		print(answer)

if __name__ == "__main__":
	main(sys.argv)


{'fraction_non_alphanumeric': 0.13814041745730551, 'fraction_numerical': 0.013282732447817837, 'mean_word_length': 4.755458515283843, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 8, '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': '3443398', 'n_tokens_mistral': 1068, 'n_tokens_neox': 975, 'n_words': 264}