Beispiel #1
0
def main():
    args = docopt(__doc__)

    use_duration = True if args["-D"] else False
    window = int(args["-w"])

    models = model.extract_models(model.ZIPPED_MODELS)

    if args["-B"]:
        models = classification.binarize(models)

    for line in sys.stdin:
        splitted = line.strip().split("\t")

        if len(splitted) == 5:
            mid_terminal, uid, bid, aid, histories = splitted
            term = classification.terminal_name(mid_terminal)
            paths = stream.decode(histories)
            assert len(paths) == 1

            decision = classification.query(term, paths[0], models, use_duration=use_duration, window=window)

            if decision:
                forward(
                    mid_terminal,
                    uid,
                    bid,
                    aid,
                    decision.decision,
                    decision.prob,
                    decision.path,
                    decision.probs,
                    decision.principal,
                )
Beispiel #2
0
def update(models, key, histories):
    histories = stream.decode(histories)
    models[key].update_all(histories)