From 01071c8123e6b30eeff88272bf4fc7325d62dd5a Mon Sep 17 00:00:00 2001 From: Houyhnhnm Date: Sun, 3 Jun 2018 18:47:29 +0200 Subject: added syntax tree generation, feature unification --- grammar.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'grammar.py') diff --git a/grammar.py b/grammar.py index 2f8e385..44e110b 100644 --- a/grammar.py +++ b/grammar.py @@ -2,16 +2,12 @@ from cadence import * from numpy import array from numpy.random import choice, seed - - class Grammar(object): def __init__(self, phonology=None, morphology=None, syntax=None): - self.phonology - self.morphology - self.syntax - - + self.phonology = phonology + self.morphology = morphology + self.syntax = syntax class Phonology(object): @@ -124,6 +120,12 @@ class Morphology(object): def addProlongationRule(self, projectedFeatures): self.prolongationRules.append(projectedFeatures) + def selectAnticipation(self): + return choice(self.anticipationRules) + + def selectProlongation(self): + return choice(self.prolongationRules) + def print(self): features = { 'anticipations': self.anticipationRules, -- cgit v1.2.3