當前位置: 首頁>>代碼示例>>Python>>正文


Python dataset_reader.DatasetReader方法代碼示例

本文整理匯總了Python中allennlp.data.dataset_readers.dataset_reader.DatasetReader方法的典型用法代碼示例。如果您正苦於以下問題:Python dataset_reader.DatasetReader方法的具體用法?Python dataset_reader.DatasetReader怎麽用?Python dataset_reader.DatasetReader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在allennlp.data.dataset_readers.dataset_reader的用法示例。


在下文中一共展示了dataset_reader.DatasetReader方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from allennlp.data.dataset_readers import dataset_reader [as 別名]
# 或者: from allennlp.data.dataset_readers.dataset_reader import DatasetReader [as 別名]
def __init__(self, model: Model, dataset_reader: DatasetReader) -> None:
        super().__init__(model, dataset_reader)
        # Due to a formatting issue, the word overlap model includes the newline character in the
        # label string. So we first create a map from the stripped label to the model label and
        # then use the model label to get the index of entailment class. It is designed in this
        # manner to also automatically handle any new models that do not have this bug.
        labels = {label.strip(): label
                  for label in self._model.vocab.get_index_to_token_vocabulary("labels").values()}

        if "entails" in labels:
            self._entailment_idx = self._model.vocab.get_token_index(labels["entails"], "labels")
        elif "entailment" in labels:
            self._entailment_idx = self._model.vocab.get_token_index(labels["entailment"], "labels")
        else:
            raise Exception("No label for entailment found in the label space: {}".format(
                ",".join(labels))) 
開發者ID:allenai,項目名稱:scitail,代碼行數:18,代碼來源:overlap_predictor.py

示例2: __init__

# 需要導入模塊: from allennlp.data.dataset_readers import dataset_reader [as 別名]
# 或者: from allennlp.data.dataset_readers.dataset_reader import DatasetReader [as 別名]
def __init__(self, model: Model, dataset_reader: DatasetReader) -> None:
        super().__init__(model, dataset_reader)
        labels = self._model.vocab.get_index_to_token_vocabulary("labels").values()
        #
        if "entails" in labels:
            self._entailment_idx = self._model.vocab.get_token_index("entails", "labels")
        elif "entailment" in labels:
            self._entailment_idx = self._model.vocab.get_token_index("entailment", "labels")
        else:
            raise Exception("No label for entailment found in the label space: {}".format(
                ",".join(labels))) 
開發者ID:allenai,項目名稱:scitail,代碼行數:13,代碼來源:decompatt_predictor.py

示例3: __init__

# 需要導入模塊: from allennlp.data.dataset_readers import dataset_reader [as 別名]
# 或者: from allennlp.data.dataset_readers.dataset_reader import DatasetReader [as 別名]
def __init__(self, model: Model, dataset_reader: DatasetReader) -> None:
        super().__init__(model, dataset_reader)
        self._stemmer = PorterStemmer()
        self._stop_words = set(stopwords.words('english')) 
開發者ID:allenai,項目名稱:ARC-Solvers,代碼行數:6,代碼來源:bidaf_qa_predictor.py


注:本文中的allennlp.data.dataset_readers.dataset_reader.DatasetReader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。