コード例 #1
0
    def __init__(self, epochs=10, eta=.0001):

        self.decoder = ViterbiDecompounder()
        self.parameters_for_epoch = []

        self.n_epochs = epochs
        self.eta = eta

        self.n_features = ViterbiDecompounder.n_features
コード例 #2
0
        modelSetup,
        nAccuracy=args.nAccuracy,
        globalNN=args.globalNN,
        similarityThreshold=args.similarityThreshold,
        prototype_file=args.prototypeFile)

    if args.mode == "lattices":
        for line in sys.stdin:
            print(
                base_decompounder.get_decompound_lattice(
                    line.decode('utf8').rstrip('\n').title(), ))
    elif args.mode == "w2v_dict":
        for word in base_decompounder.model.vocab.keys():
            print word.encode('utf-8')
    elif args.mode in ["1-best", "dict_w2v"]:
        vit = ViterbiDecompounder()
        vit.load_weights(modelSetup["WEIGHTS"])

        words = []
        if args.mode == "1-best":
            words = map(lambda line: line.decode('utf8').strip(), sys.stdin)
        else:
            words = base_decompounder.model.vocab.keys()

        print >> sys.stderr, "# words: %d" % len(words)

        def process_word(word):
            lattice = Lattice(base_decompounder.get_decompound_lattice(word))
            viterbi_path = vit.viterbi_decode(Compound(word, None, lattice))
            return [
                word.encode('utf-8'),