示例#1
0
文件: corpus.py 项目: hsensoy/uparse
def idg(filename):
    dg = DependencyGraph()
    with open(filename) as fp:
        for line in fp:
            trimmed = line.strip()

            if len(trimmed) == 0:
                yield dg
                dg = DependencyGraph()
            else:
                dg.addNode(Node.byline(trimmed))

    if dg.length() > 0:
        yield dg
示例#2
0
from filter import alldgiter
from common import DependencyGraph

alldg = [dg for dg in alldgiter('conll/*/*.dp')]

import random
done = False
while not done:
	i = random.randint(0, len(alldg) -1)

	print str(alldg[i])
	print
	print str(DependencyGraph.filteredcopy(alldg[i]))
	print "-"*10
	while True:
		inpt = raw_input('Continue[y/n] ').upper()
		if inpt in ('Y','N'):
			if inpt == 'N':
				done = True
			break