def learn_from_treebanks(self, treebanks):
        self.sym_count = Counter()
        self.unary_count = Counter()
        self.binary_count = Counter()
        self.words_count = Counter()
        
        for treebank in treebanks:
            for s in open(treebank):
                self.__count(loads(s))
        
        # Words
        for word, count in self.words_count.iteritems():
            if count >= PCFG.RARE_WORD_COUNT:
                self.well_known_words.add(word)
        
        # Normalise the unary rules count
        norm = Counter()
        for (x, word), count in self.unary_count.iteritems():
            norm[(x, self.norm_word(word))] += count
        self.unary_count = norm
        
        # Q1
        for (x, word), count in self.unary_count.iteritems():
            self.q1[x, word] = self.unary_count[x, word] / self.sym_count[x]
        
        # Q2
        for (x, y1, y2), count in self.binary_count.iteritems():
            self.q2[x, y1, y2] = self.binary_count[x, y1, y2] / self.sym_count[x]
        
        self.__build_caches()
dataset/ETHPy150Open emilmont/pyStatParser/stat_parser/pcfg.py/PCFG.learn_from_treebanks/original