<commit_before>#!/usr/bin/python 

# This script takes the timbl srl predictions and inserts them into the 
# original naf file. 
#
# Author: <NAME> (<EMAIL>) 
# Date: 27 September 2014

#
# Update 20 February 2015:
# It seems there was a bug in writing the correct term_ids, 
# namely the last term_id wasn't copied over to the role span
# This is fixed in this version

from KafNafParserPy import *
import sys 
import datetime
import time
import pprint
import re

# Make sure you get the order of the input files right 
nafinput = sys.argv[1]
timblpredictions = sys.argv[2]

my_parser = KafNafParser(nafinput)
		
## Create header info
lp = Clp()
lp.set_name('SoNaR-News-trained-SRL')
lp.set_version('1.0')
lp.set_timestamp()
my_parser.add_linguistic_processor('srl', lp)

# If the naf file already contains predicates, store those to make sure 
# you don't overwrite them or create new predicate elements for existing predicates
roles = []
predicate_spans = []
for predicate in my_parser.get_predicates():
	for role in predicate.get_roles():
		role_id = role.get_id()
		role_id = re.sub("r","",role_id)
		roles.append(int(role_id))
	for span in predicate.get_span():
		span_id = predicate.get_id()
		span_id = re.sub("pr","",span_id)
		predicate_spans.append(int(span_id))
		
predicate = ''
if len(predicate_spans) > 0:
	pred_counter = max(predicate_spans)
else:
	pred_counter = 0 
if len(roles) > 0:		
	role_counter = max(roles)
else:
	role_counter = 0 

# Go through the timbl output file <commit_msg>Update timblToAlpinoNAF.py<commit_after>#!/usr/bin/python 

# This script takes the timbl srl predictions and inserts them into the 
# original naf file. 
#
# Author: <NAME> (<EMAIL>) 
# Date: 27 September 2014

#
# Update 20 February 2015:
# It seems there was a bug in writing the correct term_ids, 
# namely the last term_id wasn't copied over to the role span
# This is fixed in this version

from KafNafParserPy import *
import sys 
import datetime
import time
import pprint
import re

# Make sure you get the order of the input files right 
nafinput = sys.argv[1]
timblpredictions = sys.argv[2]

my_parser = KafNafParser(nafinput)
		
## Create header info
lp = Clp()
lp.set_name('SoNaR-News-trained-SRL')
lp.set_version('1.1')
lp.set_timestamp()
my_parser.add_linguistic_processor('srl', lp)

# If the naf file already contains predicates, store those to make sure 
# you don't overwrite them or create new predicate elements for existing predicates
roles = []
predicate_spans = []
for predicate in my_parser.get_predicates():
	for role in predicate.get_roles():
		role_id = role.get_id()
		role_id = re.sub("r","",role_id)
		roles.append(int(role_id))
	for span in predicate.get_span():
		span_id = predicate.get_id()
		span_id = re.sub("pr","",span_id)
		predicate_spans.append(int(span_id))
		
predicate = ''
if len(predicate_spans) > 0:
	pred_counter = max(predicate_spans)
else:
	pred_counter = 0 
if len(roles) > 0:		
	role_counter = max(roles)
else:
	role_counter = 0 

# Go through the timbl output file 
{'fraction_non_alphanumeric': 0.1015547469401257, 'fraction_numerical': 0.013231888852133642, 'mean_word_length': 4.6103896103896105, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '4511832', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1047, 'n_words': 333}