def main():
    lines = sys.__stdin__.readlines()
    tmp = []
    for line in lines:
        if line.strip() == '':
            s_len = len(tmp[0])
            etree = mst2etree(tmp)
            root = etree.getroot()
            b_table = create_between_pos_table(tmp[1].strip().split())
            extract_label_features(root,s_len,b_table)
            tmp = []
        else:
            tmp.append(line)
def main():
	lines = sys.__stdin__.readlines()
	tmp = []

	for line in lines:
		if line.strip() != '':
			tmp.append(line.strip())
		else:
			W = map(encode_number,map(str.strip,tmp[0].split('\t')))
			T = map(str.strip,tmp[1].split('\t'))
			H = map(str.strip,tmp[-1].split('\t'))

			if len(W) < 2:
				continue

			nW = []
			for i in range(len(W)):
				if T[i] == 'npn':
					nW.append('<npn>')
				else:
					nW.append(W[i])
			W = nW

			units = [(W[i].replace(' ','_'),T[i],H[i]) for i in range(len(W))]
			pairs = [(int(h),i+1) for i,h in enumerate(H)]

			b_table = create_between_pos_table(T)

			for i in range(1,len(W)+1,1):
				for j in range(1,len(W)+1,1):
					if i != j:
						if (i,j) in pairs:
							print 'Yes',extract_mira_features(i-1,j-1,units,b_table)
						else:
							print 'No',extract_mira_features(i-1,j-1,units,b_table)

			tmp = []
Example #3
0
def main():
    lines = sys.__stdin__.readlines()
    tmp = []

    for line in lines:
        if line.strip() != '':
            tmp.append(line.strip())
        else:
            W = ['<root>'] + map(encode_number,map(str.strip,tmp[0].split('\t')))
            T = ['<root-POS>'] + map(str.strip,tmp[1].split('\t'))
            H = [-1] + map(str.strip,tmp[-1].split('\t'))

            if len(W) < 2:
                continue

            nW = []
            for i in range(len(W)):
                if T[i] == 'npn':
                    nW.append('<npn>')
                else:
                    nW.append(W[i])
            W = nW

            units = [(W[i].replace(' ','_'),T[i],H[i]) for i in range(len(W))]
            pairs = [(int(h),i) for i,h in enumerate(H)]

            b_table = create_between_pos_table(T)

            for i in range(len(W)):
                for j in range(i+1,len(W),1):
                    for di in ['L','R']:
                        ans = 'No'
                        if (di == 'L' and (j,i) in pairs) or (di == 'R' and (i,j) in pairs):
                            ans = 'Yes'
                        print ans,extract_features(i,j,di,units,b_table)
            tmp = []