def saveModel(self):
        # write out the markov model:
        f = file(self.datapath + ".markovModel", "w")
        for state, nextStates in self.mc.iteritems():
            for nextState, count in nextStates.iteritems():
                f.write("%s->%s,%d\n" % (state, nextState, count))
        f.close()
        # write out the templates:
        f = file(self.datapath + ".templates", "w")
        for template in self.structureTemplates:
            f.write("TEMPLATE id:%d state:%s count:%d ntokens:%d fields:%s\n" %
                    (template.templateId, template.state,
                     template.numberOfMessages, len(template.tokens),
                     ",".join(map(str, template.getFieldIndices()))))
            for tok in template.tokens:
                f.write("%s\n" % urllib.quote(tok))
        f.close()
        f = file(self.datapath + ".rules", "w")
        for ruleSet in self.rules.itervalues():
            for r in ruleSet.rules:
                f.write("RULE transition:%s srcId:%d srcField:%d dstField:%d type:%s\n" %
                        (ruleSet.fingerprint, r.sourceId, r.sourceField,
                         r.targetField, str(r.__class__)))
                f.write(r.getSpecificSaveString() % "%s\n")
        f.close()
dataset/ETHPy150Open hgascon/pulsar/pulsar/core/model.py/ModelFilesGenerator.saveModel/swapped operands of `%`