脚本错误:没有名为common.hyperparameters的模块

时间:2015-06-04 05:04:42

标签: python nlp

我正在尝试运行以下代码:

#!/usr/bin/env python

if __name__ == "__main__":
**import common.hyperparameters, common.options**
HYPERPARAMETERS = common.hyperparameters.read("language-model")
HYPERPARAMETERS, options, args, newkeystr = common.options.reparse(HYPERPARAMETERS)
import hyperparameters

import vocabulary
import common.idmap

words = []

import string
for i, l in enumerate(common.file.myopen(HYPERPARAMETERS["MONOLINGUAL_VOCABULARY"])):
    if HYPERPARAMETERS["INCLUDE_UNKNOWN_WORD"] and i+1 >= HYPERPARAMETERS["MONOLINGUAL_VOCABULARY_SIZE"]:
        break
    if not HYPERPARAMETERS["INCLUDE_UNKNOWN_WORD"] and i >= HYPERPARAMETERS["MONOLINGUAL_VOCABULARY_SIZE"]:
        break
    (cnt, w) = string.split(l)
    words.append(w)

v = common.idmap.IDmap(words, allow_unknown=HYPERPARAMETERS["INCLUDE_UNKNOWN_WORD"])
assert v.len == HYPERPARAMETERS["MONOLINGUAL_VOCABULARY_SIZE"]
vocabulary.write(v)

这里我有一个包含hyperparameters.py的公共文件夹,即便这样也无法将该脚本合并到我的主程序中。我不知道如何将其添加到我的程序中。

0 个答案:

没有答案