Esempio n. 1
0
class TestTyper(unittest.TestCase):
    def setUp(self):
        self.t = Typer()

    def tearDown(self):
        self.t = None

    def test(self):
        self.assertEqual(self.t.type("tha", "V-p", "BIPP")[1], "s[dcl pres cons]/pp/n")
        self.assertEqual(self.t.type("bha", "V-s", "BIPP")[1], "s[dcl past cons]/pp/n")
Esempio n. 2
0
 def setUp(self):
     self.t = Typer()
Esempio n. 3
0
        return s.replace("&", "&")

brownfile = open(sys.argv[1], 'rb')
corpus = pickle.load(brownfile)
brownfile.close()
output = open(sys.argv[2], 'w')
# features
with open("resources/features.txt") as f:
    for line in f:
        output.write(line)
# type-changing and type-raising rules
with open("resources/rules.txt") as r:
    for line in r:
        output.write(line)
retagger = Retagger()
typer = Typer()
families = set()
words = set()
# assumes a single list rather than a list of lists (need to think about this)
for surface, pos in corpus:
    if pos != "":
        tags = retagger.retag(surface, pos)
        for tag in tags:
            newtagtype = typer.type(surface, pos, tag)
            newtag = newtagtype[0]
            type = newtagtype[1]
            families.add("family %s { entry: %s; }" % (newtag, type))
            words.add('word "%s_%s":%s; # %s' % (tidyword(surface), newtag, newtag, pos))

for family in sorted(families):
    output.write(family + '\n')