def __init__(self, lhs, rhs): """ lhs: string rhs: strinf """ this._lhs = AttributeSet(lhs) this._rhs = AttributeSet(rhs)
def __init__(self, attrs, fds): """ attrs: string fds: functional dependencies in object form """ self._attrs = AttributeSet(attrs) self._fds = set() for lhs, rhs in fds.items(): self._fds.add(FD(lhs, rhs))
return [labels.count(l) for l in self.getLabels()] def getFrequencies(self): c = self.getCounts() n = sum(c) * 1. return [x / n for x in c] if __name__ == "__main__": import Attribute import AttributeSet a1 = ["att", "n", "this is a test"] a2 = ["avd", "n", "this was a test"] a3 = ["avs", "c", "this will be a test"] a4 = ["kmn", "c", "this could be a test"] d1 = Attribute.Attribute(a1) d2 = Attribute.Attribute(a2) d3 = Attribute.Attribute(a3) d4 = Attribute.Attribute(a4) aa = AttributeSet.AttributeSet() aa.add(d1) aa.add(d2) aa.add(d3) aa.add(d4) print aa.get(0).getValues()