python_code
stringlengths
0
187k
repo_name
stringlengths
8
46
file_path
stringlengths
6
135
import pytest from allennlp.common import Params from allennlp.common.util import ensure_list from allennlp.common.testing import AllenNlpTestCase from allennlp_models.classification import StanfordSentimentTreeBankDatasetReader from tests import FIXTURES_ROOT class TestStanfordSentimentTreebankReader: sst_path...
allennlp-models-main
tests/classification/dataset_readers/stanford_sentiment_tree_bank_test.py
# -*- coding: utf-8 -*- from allennlp.common.util import ensure_list from allennlp.data.tokenizers import PretrainedTransformerTokenizer from allennlp.data.token_indexers import PretrainedTransformerIndexer from allennlp_models.classification import BoolQDatasetReader from tests import FIXTURES_ROOT class TestBoolqR...
allennlp-models-main
tests/classification/dataset_readers/boolq.py
from copy import deepcopy import pytest from allennlp.common.testing import ModelTestCase from allennlp.common.checks import ConfigurationError from allennlp.common.params import Params from allennlp.models import Model from tests import FIXTURES_ROOT class BiattentiveClassificationNetworkTest(ModelTestCase): ...
allennlp-models-main
tests/classification/models/biattentive_classification_network_test.py
allennlp-models-main
tests/classification/models/__init__.py
import pytest def test_gradient_visualization(): from allennlp.predictors.predictor import Predictor predictor = Predictor.from_path( "https://storage.googleapis.com/allennlp-public-models/sst-roberta-large-2020.06.08.tar.gz" ) sentence = "a very well-made, funny and entertaining picture." ...
allennlp-models-main
tests/classification/interpret/sst_test.py
allennlp-models-main
tests/classification/interpret/__init__.py
allennlp-models-main
tests/structured_prediction/__init__.py
allennlp-models-main
tests/structured_prediction/metrics/__init__.py
import pytest from numpy.testing import assert_allclose from allennlp.common.testing import ( AllenNlpTestCase, global_distributed_metric, run_distributed_test, ) from allennlp_models.structured_prediction.metrics.srl_eval_scorer import SrlEvalScorer class SrlEvalScorerTest(AllenNlpTestCase): def te...
allennlp-models-main
tests/structured_prediction/metrics/srl_eval_scorer_test.py
import os import subprocess import torch from allennlp.data import Vocabulary from torch.testing import assert_allclose from allennlp.common.testing import AllenNlpTestCase, multi_device from allennlp.training.metrics import SpanBasedF1Measure from tests import PROJECT_ROOT class SpanBasedF1Test(AllenNlpTestCase):...
allennlp-models-main
tests/structured_prediction/metrics/span_based_f1_test.py
allennlp-models-main
tests/structured_prediction/dataset_readers/__init__.py
from nltk.tree import Tree from allennlp.common.testing import AllenNlpTestCase from allennlp.data.dataset_readers.dataset_utils.span_utils import enumerate_spans from allennlp_models.structured_prediction.dataset_readers.penn_tree_bank import ( PennTreeBankConstituencySpanDatasetReader, ) from tests import FIXTU...
allennlp-models-main
tests/structured_prediction/dataset_readers/penn_tree_bank_test.py
from allennlp.common.testing import AllenNlpTestCase from allennlp_models.structured_prediction import UniversalDependenciesDatasetReader from tests import FIXTURES_ROOT class TestUniversalDependenciesDatasetReader(AllenNlpTestCase): data_path = FIXTURES_ROOT / "structured_prediction" / "dependencies.conllu" ...
allennlp-models-main
tests/structured_prediction/dataset_readers/universal_dependencies_test.py
from allennlp.common.util import ensure_list from allennlp.common.testing import AllenNlpTestCase from allennlp_models.structured_prediction.dataset_readers.srl import ( SrlReader, _convert_tags_to_wordpiece_tags, ) from tests import FIXTURES_ROOT class TestSrlReader: def test_read_from_file(self): ...
allennlp-models-main
tests/structured_prediction/dataset_readers/srl_test.py
allennlp-models-main
tests/structured_prediction/predictors/__init__.py
from allennlp.common.testing import AllenNlpTestCase from allennlp.models.archival import load_archive from allennlp.predictors import Predictor import spacy from allennlp_models.structured_prediction import BiaffineDependencyParserPredictor from tests import FIXTURES_ROOT class TestBiaffineDependencyParser(AllenNlp...
allennlp-models-main
tests/structured_prediction/predictors/biaffine_dependency_parser_test.py
from nltk import Tree import pytest from allennlp.common.testing import AllenNlpTestCase from allennlp.models.archival import load_archive from allennlp.predictors import Predictor from allennlp_models.structured_prediction.predictors.constituency_parser import ( LINK_TO_LABEL, NODE_TYPE_TO_STYLE, ) from test...
allennlp-models-main
tests/structured_prediction/predictors/constituency_parser_test.py
from allennlp.common.testing import AllenNlpTestCase from allennlp.models.archival import load_archive from allennlp.predictors import Predictor from allennlp.data.tokenizers.spacy_tokenizer import SpacyTokenizer from allennlp_models.structured_prediction.predictors.openie import ( sanitize_label, consolidate_...
allennlp-models-main
tests/structured_prediction/predictors/openie_test.py
from allennlp.common.testing import AllenNlpTestCase from allennlp.models.archival import load_archive from allennlp.predictors import Predictor from tests import FIXTURES_ROOT class TestSrlPredictor(AllenNlpTestCase): def test_uses_named_inputs(self): inputs = { "sentence": "The squirrel wro...
allennlp-models-main
tests/structured_prediction/predictors/srl_test.py
import json import numpy import pytest from transformers.models.bert.modeling_bert import BertConfig, BertModel from transformers.models.bert.tokenization_bert import BertTokenizer from allennlp.common.testing import ModelTestCase from allennlp.nn.util import get_lengths_from_binary_sequence_mask from allennlp.data.d...
allennlp-models-main
tests/structured_prediction/models/bert_srl_test.py
from allennlp.common.testing.model_test_case import ModelTestCase from tests import FIXTURES_ROOT import allennlp_models.structured_prediction class GraphParserTest(ModelTestCase): def setup_method(self): super().setup_method() self.set_up_model( FIXTURES_ROOT / "structured_prediction...
allennlp-models-main
tests/structured_prediction/models/graph_parser_test.py
import subprocess import os from flaky import flaky import pytest import numpy from allennlp.common.testing import ModelTestCase from allennlp.common.params import Params from allennlp.common.checks import ConfigurationError from allennlp.models import Model from allennlp.nn.util import get_lengths_from_binary_sequen...
allennlp-models-main
tests/structured_prediction/models/semantic_role_labeling_test.py
allennlp-models-main
tests/structured_prediction/models/__init__.py
import torch from allennlp.common.testing import ModelTestCase from allennlp.nn.chu_liu_edmonds import decode_mst from tests import FIXTURES_ROOT from allennlp_models.structured_prediction import BiaffineDependencyParser class BiaffineDependencyParserTest(ModelTestCase): def setup_method(self): super()....
allennlp-models-main
tests/structured_prediction/models/biaffine_dependency_parser_test.py
from nltk import Tree import torch from allennlp.common.testing.model_test_case import ModelTestCase from allennlp.training.metrics import EvalbBracketingScorer from allennlp_models.structured_prediction.models.constituency_parser import SpanInformation from tests import FIXTURES_ROOT class SpanConstituencyParserTe...
allennlp-models-main
tests/structured_prediction/models/constituency_parser_test.py
allennlp-models-main
tests/lm/__init__.py
from allennlp.common.testing import AllenNlpTestCase from allennlp.data import Vocabulary from allennlp.data.tokenizers import PretrainedTransformerTokenizer from allennlp.data.token_indexers import PretrainedTransformerIndexer from allennlp_models.lm import MaskedLanguageModelingReader class TestMaskedLanguageModel...
allennlp-models-main
tests/lm/dataset_readers/masked_language_modeling_test.py
allennlp-models-main
tests/lm/dataset_readers/__init__.py
from allennlp.common.testing import AllenNlpTestCase from allennlp.data import Vocabulary from allennlp.data.tokenizers import PretrainedTransformerTokenizer from allennlp.data.token_indexers import PretrainedTransformerIndexer from allennlp_models.lm import NextTokenLMReader class TestNextTokenLMReader(AllenNlpTest...
allennlp-models-main
tests/lm/dataset_readers/next_token_lm_test.py
import os from typing import cast from allennlp.common.testing import AllenNlpTestCase from allennlp.data.fields import TextField from allennlp_models.lm import SimpleLanguageModelingDatasetReader from tests import FIXTURES_ROOT class TestSimpleLanguageModelingDatasetReader(AllenNlpTestCase): FIXTURES = FIXTURE...
allennlp-models-main
tests/lm/dataset_readers/simple_language_modeling_test.py
allennlp-models-main
tests/lm/predictors/__init__.py
from allennlp.common.testing import AllenNlpTestCase from allennlp.models.archival import load_archive from allennlp.predictors import Predictor from tests import FIXTURES_ROOT class TestMaskedLanguageModelPredictor(AllenNlpTestCase): def test_predictions_to_labeled_instances(self): inputs = {"sentence":...
allennlp-models-main
tests/lm/predictors/masked_language_model_test.py
from allennlp.common.testing import AllenNlpTestCase from allennlp.models.archival import load_archive from allennlp.predictors import Predictor from tests import FIXTURES_ROOT from allennlp_models import lm # noqa: F401 class TestNextTokenLMPredictor(AllenNlpTestCase): def test_predictions_to_labeled_instances...
allennlp-models-main
tests/lm/predictors/next_token_lm_test.py
allennlp-models-main
tests/lm/models/__init__.py
from allennlp.common.testing import ModelTestCase from tests import FIXTURES_ROOT class TestMaskedLanguageModel(ModelTestCase): def setup_method(self): super().setup_method() self.set_up_model( FIXTURES_ROOT / "lm" / "masked_language_model" / "experiment.json", FIXTURES_RO...
allennlp-models-main
tests/lm/models/masked_language_model_test.py
from allennlp.common.testing import ModelTestCase from tests import FIXTURES_ROOT from allennlp_models import lm # noqa: F401 class TestNextTokenLanguageModel(ModelTestCase): def setup_method(self): super().setup_method() self.set_up_model( FIXTURES_ROOT / "lm" / "next_token_lm" / "e...
allennlp-models-main
tests/lm/models/next_token_lm_test.py
import numpy as np import pytest from allennlp.common.testing import ModelTestCase from allennlp.common.checks import ConfigurationError from allennlp.common.params import Params from allennlp.models import Model from tests import FIXTURES_ROOT class LmBaseTestCase(ModelTestCase): def setup_method(self): ...
allennlp-models-main
tests/lm/models/language_model_test.py
import numpy as np from allennlp.common.testing import ModelTestCase from tests import FIXTURES_ROOT import allennlp_models.lm class TestBidirectionalLanguageModel(ModelTestCase): def setup_method(self): super().setup_method() self.expected_embedding_shape = (2, 8, 14) self.set_up_mod...
allennlp-models-main
tests/lm/models/bidirectional_lm_test.py
from allennlp.common.testing import AllenNlpTestCase from allennlp.interpret.attackers import Hotflip from allennlp.models.archival import load_archive from allennlp.predictors import Predictor from allennlp_models.lm import LinearLanguageModelHead from tests import FIXTURES_ROOT class TestHotflip(AllenNlpTestCase):...
allennlp-models-main
tests/lm/interpret/lm_hotflip_test.py
from allennlp.common.testing import AllenNlpTestCase from allennlp.interpret.saliency_interpreters import SimpleGradient from allennlp.models.archival import load_archive from allennlp.predictors import Predictor from tests import FIXTURES_ROOT class TestSimpleGradient(AllenNlpTestCase): def test_simple_gradient...
allennlp-models-main
tests/lm/interpret/simple_gradient_test.py
allennlp-models-main
tests/lm/interpret/__init__.py
allennlp-models-main
tests/lm/modules/__init__.py
import torch from allennlp.common.testing import AllenNlpTestCase from allennlp_models.lm import BidirectionalLanguageModelTransformer class TestBidirectionalLanguageModelTransformer(AllenNlpTestCase): def test_bidirectional_transformer_encoder(self): transformer_encoder = BidirectionalLanguageModelTran...
allennlp-models-main
tests/lm/modules/seq2seq_encoders/bidirectional_lm_transformer_test.py
allennlp-models-main
tests/lm/modules/seq2seq_encoders/__init__.py
allennlp-models-main
tests/lm/modules/language_model_heads/__init__.py
import torch from allennlp.common import Params from allennlp.common.testing.test_case import AllenNlpTestCase from allennlp_models.lm.modules.language_model_heads import LanguageModelHead, BertLanguageModelHead class TestBertLanguageModelHead(AllenNlpTestCase): def test_can_init_and_run(self): # The LM...
allennlp-models-main
tests/lm/modules/language_model_heads/bert_test.py
import torch from allennlp.common import Params from allennlp.common.testing.test_case import AllenNlpTestCase from allennlp_models.lm.modules.language_model_heads import LanguageModelHead, Gpt2LanguageModelHead class TestGpt2LanguageModelHead(AllenNlpTestCase): def test_can_init_and_run(self): # The LM...
allennlp-models-main
tests/lm/modules/language_model_heads/gpt2_test.py
allennlp-models-main
tests/lm/modules/token_embedders/__init__.py
from allennlp.common.testing import ModelTestCase from allennlp.data.batch import Batch from tests import FIXTURES_ROOT class TestLanguageModelTokenEmbedder(ModelTestCase): def setup_method(self): super().setup_method() self.set_up_model( FIXTURES_ROOT / "lm" / "language_model" / "cha...
allennlp-models-main
tests/lm/modules/token_embedders/language_model_test.py
from tests import FIXTURES_ROOT from tests.lm.modules.token_embedders.language_model_test import TestLanguageModelTokenEmbedder class TestBidirectionalLanguageModelTokenEmbedder(TestLanguageModelTokenEmbedder): def setup_method(self): super().setup_method() self.set_up_model( FIXTURES_...
allennlp-models-main
tests/lm/modules/token_embedders/bidirectional_lm_test.py
allennlp-models-main
tests/vision/__init__.py
from typing import Any, Dict, List, Tuple, Union import pytest import torch from allennlp.common.testing import ( AllenNlpTestCase, multi_device, global_distributed_metric, run_distributed_test, ) from allennlp_models.vision import VqaMeasure class VqaMeasureTest(AllenNlpTestCase): @multi_device...
allennlp-models-main
tests/vision/metrics/vqa_test.py
from allennlp.common.lazy import Lazy from allennlp.common.testing import AllenNlpTestCase from allennlp.data.image_loader import TorchImageLoader from allennlp.modules.vision.grid_embedder import NullGridEmbedder from allennlp.modules.vision.region_detector import RandomRegionDetector from allennlp_models.vision.datas...
allennlp-models-main
tests/vision/dataset_readers/vision_reader_test.py
import torch from allennlp.common.testing import AllenNlpTestCase from allennlp.common.lazy import Lazy from allennlp.data import Batch, Vocabulary from allennlp.data.image_loader import TorchImageLoader from allennlp.data.tokenizers import WhitespaceTokenizer from allennlp.data.token_indexers import SingleIdTokenInde...
allennlp-models-main
tests/vision/dataset_readers/vgqa_test.py
from allennlp.common.lazy import Lazy from allennlp.common.testing import AllenNlpTestCase from allennlp.data import Batch, Vocabulary from allennlp.data.image_loader import TorchImageLoader from allennlp.data.tokenizers import WhitespaceTokenizer from allennlp.data.token_indexers import SingleIdTokenIndexer from allen...
allennlp-models-main
tests/vision/dataset_readers/visual_entailment_test.py
import torch from allennlp.common.testing import AllenNlpTestCase from allennlp.common.lazy import Lazy from allennlp.data import Batch, Vocabulary from allennlp.data.image_loader import TorchImageLoader from allennlp.data.tokenizers import WhitespaceTokenizer from allennlp.data.token_indexers import SingleIdTokenInde...
allennlp-models-main
tests/vision/dataset_readers/vqav2_test.py
from allennlp.common.lazy import Lazy from allennlp.common.testing import AllenNlpTestCase from allennlp.data import Batch, Vocabulary from allennlp.data.image_loader import TorchImageLoader from allennlp.data.tokenizers import WhitespaceTokenizer from allennlp.data.token_indexers import SingleIdTokenIndexer from allen...
allennlp-models-main
tests/vision/dataset_readers/gqa_test.py
from allennlp.common.testing import AllenNlpTestCase from allennlp.common.lazy import Lazy from allennlp.data import Batch, Vocabulary from allennlp.data.image_loader import TorchImageLoader from allennlp.data.tokenizers import WhitespaceTokenizer from allennlp.data.token_indexers import SingleIdTokenIndexer from allen...
allennlp-models-main
tests/vision/dataset_readers/nlvr2_test.py
from allennlp.common.lazy import Lazy from allennlp.common.testing import AllenNlpTestCase from allennlp.data import Batch, Vocabulary from allennlp.data.image_loader import TorchImageLoader from allennlp.data.tokenizers import WhitespaceTokenizer from allennlp.data.token_indexers import SingleIdTokenIndexer from allen...
allennlp-models-main
tests/vision/dataset_readers/flickr30k_test.py
from torch.testing import assert_allclose from transformers import AutoModel from allennlp.common.testing import ModelTestCase from allennlp.data import Vocabulary from allennlp.common.testing import assert_equal_parameters from allennlp_models import vision # noqa: F401 from tests import FIXTURES_ROOT class Test...
allennlp-models-main
tests/vision/models/vilbert_ir_test.py
from torch.testing import assert_allclose from transformers import AutoModel from allennlp.common.testing import ModelTestCase from allennlp.data import Vocabulary from allennlp_models.vision.models.vilbert_vqa import VqaVilbert from tests import FIXTURES_ROOT class TestVqaVilbert(ModelTestCase): def test_model...
allennlp-models-main
tests/vision/models/vilbert_vqa_test.py
from torch.testing import assert_allclose from transformers import AutoModel from allennlp.common.testing import ModelTestCase from allennlp.data import Vocabulary from allennlp.common.testing import assert_equal_parameters from allennlp_models import vision # noqa: F401 from tests import FIXTURES_ROOT class Test...
allennlp-models-main
tests/vision/models/vilbert_nlvr2_test.py
from allennlp.common.testing import ModelTestCase from tests import FIXTURES_ROOT class TestVilbertMultitask(ModelTestCase): def test_predict(self): from allennlp.models import load_archive from allennlp.predictors import Predictor import allennlp_models.vision archive = load_arc...
allennlp-models-main
tests/vision/models/vilbert_multitask_test.py
allennlp-models-main
tests/vision/models/__init__.py
from torch.testing import assert_allclose from transformers import AutoModel from allennlp.common.testing import ModelTestCase from allennlp.data import Vocabulary from allennlp_models import vision # noqa: F401 from tests import FIXTURES_ROOT class TestVEVilbert(ModelTestCase): def test_model_can_train_save_...
allennlp-models-main
tests/vision/models/visual_entailment_test.py
allennlp-models-main
tests/pair_classification/__init__.py
import random import pytest from allennlp.confidence_checks.task_checklists.textual_entailment_suite import ( TextualEntailmentSuite, ) from allennlp.common.testing import AllenNlpTestCase from allennlp.models.archival import load_archive from allennlp.predictors import Predictor import torch import numpy from al...
allennlp-models-main
tests/pair_classification/task_checklists/textual_entailment_suite_test.py
allennlp-models-main
tests/pair_classification/task_checklists/__init__.py
from allennlp.common.params import Params from allennlp.common.util import ensure_list from allennlp.data import DatasetReader import pytest from allennlp_models.pair_classification import TransformerSuperGlueRteReader from tests import FIXTURES_ROOT class TestTransformerSuperGlueRteReader: def test_read_from_fi...
allennlp-models-main
tests/pair_classification/dataset_readers/transformer_superglue_rte_test.py
import pytest from allennlp.data.tokenizers import PretrainedTransformerTokenizer from allennlp.common.util import ensure_list from allennlp_models.pair_classification import SnliReader from tests import FIXTURES_ROOT class TestSnliReader: def test_read_from_file(self): reader = SnliReader() ins...
allennlp-models-main
tests/pair_classification/dataset_readers/snli_test.py
from allennlp.common.util import ensure_list from allennlp_models.pair_classification.dataset_readers.quora_paraphrase import ( QuoraParaphraseDatasetReader, ) from tests import FIXTURES_ROOT class TestQuoraParaphraseReader: def test_read_from_file(self): reader = QuoraParaphraseDatasetReader() ...
allennlp-models-main
tests/pair_classification/dataset_readers/quora_paraphrase_test.py
allennlp-models-main
tests/pair_classification/dataset_readers/__init__.py
from allennlp.common.testing import ModelTestCase from tests import FIXTURES_ROOT class TestBiMPM(ModelTestCase): def setup_method(self): super().setup_method() self.set_up_model( FIXTURES_ROOT / "pair_classification" / "bimpm" / "experiment.json", FIXTURES_ROOT / "pair_cl...
allennlp-models-main
tests/pair_classification/models/bimpm_test.py
from flaky import flaky import numpy from tests import FIXTURES_ROOT from allennlp.common.testing import ModelTestCase from allennlp_models.pair_classification import SnliReader from allennlp.fairness import ( AdversarialBiasMitigator, FeedForwardRegressionAdversary, AdversarialBiasMitigatorBackwardCallbac...
allennlp-models-main
tests/pair_classification/models/adversarial_bias_mitigator_test.py
from flaky import flaky import numpy from tests import FIXTURES_ROOT from allennlp.common.testing import ModelTestCase from allennlp_models.pair_classification import SnliReader from allennlp.fairness.bias_mitigator_applicator import BiasMitigatorApplicator class BiasMitigatorApplicatorTest(ModelTestCase): def s...
allennlp-models-main
tests/pair_classification/models/bias_mitigator_applicator_test.py
allennlp-models-main
tests/pair_classification/models/__init__.py
from allennlp.models import Model from flaky import flaky import pytest import numpy from numpy.testing import assert_almost_equal from allennlp.common import Params from allennlp.common.checks import ConfigurationError from allennlp.common.testing import ModelTestCase from allennlp_models.pair_classification import ...
allennlp-models-main
tests/pair_classification/models/decomposable_attention_test.py
import numpy from numpy.testing import assert_almost_equal from allennlp.common.testing import ModelTestCase from tests import FIXTURES_ROOT class TestESIM(ModelTestCase): def setup_method(self): super().setup_method() self.set_up_model( FIXTURES_ROOT / "pair_classification" / "esim"...
allennlp-models-main
tests/pair_classification/models/esim_test.py
allennlp-models-main
tests/tagging/__init__.py
allennlp-models-main
tests/tagging/dataset_readers/__init__.py
from allennlp.common.util import ensure_list from allennlp_models.tagging.dataset_readers.ontonotes_ner import OntonotesNamedEntityRecognition from tests import FIXTURES_ROOT class TestOntonotesNamedEntityRecognitionReader: def test_read_from_file(self): conll_reader = OntonotesNamedEntityRecognition() ...
allennlp-models-main
tests/tagging/dataset_readers/ontonotes_ner_test.py
from allennlp.common.util import ensure_list from allennlp.common.testing import AllenNlpTestCase from allennlp.data.vocabulary import Vocabulary from allennlp_models.tagging import CcgBankDatasetReader from tests import FIXTURES_ROOT class TestCcgBankReader(AllenNlpTestCase): def test_read_from_file(self): ...
allennlp-models-main
tests/tagging/dataset_readers/ccgbank_test.py
import pytest from allennlp_models.tagging import Conll2000DatasetReader from allennlp.common.util import ensure_list from tests import FIXTURES_ROOT class TestConll2000Reader: @pytest.mark.filterwarnings("ignore::DeprecationWarning") @pytest.mark.parametrize("coding_scheme", ("BIO", "BIOUL")) def test_...
allennlp-models-main
tests/tagging/dataset_readers/conll2000_test.py
from flaky import flaky import pytest from allennlp.commands.train import train_model_from_file from allennlp.common.testing import ModelTestCase from allennlp.common.checks import ConfigurationError from allennlp.common.params import Params from allennlp.models import Model from tests import FIXTURES_ROOT class Cr...
allennlp-models-main
tests/tagging/models/crf_tagger_test.py
allennlp-models-main
tests/tagging/models/__init__.py
from flaky import flaky import pytest from allennlp.commands.train import train_model_from_file from allennlp.common.testing import ModelTestCase from allennlp.common.checks import ConfigurationError from tests import FIXTURES_ROOT class CrfTaggerLabelWeightsTest(ModelTestCase): def setup_method(self): ...
allennlp-models-main
tests/tagging/models/crf_tagger_label_weights_test.py
from nltk import Tree from allennlp.common.testing import AllenNlpTestCase from allennlp_models.common.ontonotes import Ontonotes from tests import FIXTURES_ROOT CONLL_PATH = FIXTURES_ROOT / "structured_prediction" / "srl" / "conll_2012" class TestOntonotes(AllenNlpTestCase): def test_dataset_iterator(self): ...
allennlp-models-main
tests/common/ontonotes_test.py
import pytest from allennlp.common.util import ensure_list from allennlp_models.mc.dataset_readers.commonsenseqa import CommonsenseQaReader from tests import FIXTURES_ROOT class TestCommonsenseQaReader: def test_read_from_file(self): reader = CommonsenseQaReader(transformer_model_name="bert-base-uncased...
allennlp-models-main
tests/mc/dataset_readers/commonsenseqa_test.py
import pytest from allennlp.common.util import ensure_list from allennlp_models.mc.dataset_readers.piqa import PiqaReader from tests import FIXTURES_ROOT class TestCommonsenseQaReader: def test_read_from_file(self): reader = PiqaReader(transformer_model_name="bert-base-uncased") instances = ensu...
allennlp-models-main
tests/mc/dataset_readers/piqa_test.py
import pytest from allennlp.common.util import ensure_list from allennlp_models.mc.dataset_readers.swag import SwagReader from tests import FIXTURES_ROOT class TestSwagReader: def test_read_from_file(self): reader = SwagReader(transformer_model_name="bert-base-uncased") instances = ensure_list(r...
allennlp-models-main
tests/mc/dataset_readers/swag_test.py
from flaky import flaky from allennlp.commands.train import train_model_from_file from allennlp.common.testing import ModelTestCase, AllenNlpTestCase, requires_gpu from allennlp.data import Batch from tests import FIXTURES_ROOT import pytest import allennlp_models.mc.models class TransformerMcTest(ModelTestCase): ...
allennlp-models-main
tests/mc/models/transformer_mc_test.py
# These test should really be in the core repo, but they are here because the multitask model is # here. import json import os import pathlib import shutil import sys import tempfile import pytest from allennlp.commands import main from allennlp.common.checks import ConfigurationError from allennlp.common.testing imp...
allennlp-models-main
tests/commands/multitask_predict_test.py
allennlp-models-main
tests/rc/__init__.py
from allennlp.common.testing import ( AllenNlpTestCase, global_distributed_metric, run_distributed_test, ) from allennlp_models.rc.metrics import DropEmAndF1 class DropEmAndF1Test(AllenNlpTestCase): def test_drop_em_and_f1(self): metric = DropEmAndF1() metric( "this is th...
allennlp-models-main
tests/rc/metrics/drop_em_and_f1_test.py
from allennlp.common.testing import ( AllenNlpTestCase, global_distributed_metric, run_distributed_test, ) from allennlp_models.rc.metrics import SquadEmAndF1 class SquadEmAndF1Test(AllenNlpTestCase): def test_squad_em_and_f1(self): metric = SquadEmAndF1() metric("this is the best sp...
allennlp-models-main
tests/rc/metrics/squad_em_and_f1_test.py
import pytest from allennlp.confidence_checks.task_checklists.question_answering_suite import ( QuestionAnsweringSuite, ) from allennlp.common.testing import AllenNlpTestCase from allennlp.models.archival import load_archive from allennlp.predictors import Predictor from allennlp_models.rc.predictors import * # n...
allennlp-models-main
tests/rc/task_checklists/question_answering_suite_test.py
allennlp-models-main
tests/rc/task_checklists/__init__.py
import os from allennlp.common.testing import AllenNlpTestCase from allennlp_models.rc.tools import quoref from tests import FIXTURES_ROOT class TestQuorefEval(AllenNlpTestCase): """ The actual evaluation logic in Quoref's evaluation script is from DROP's script, and the only additional thing that Quore...
allennlp-models-main
tests/rc/evaluations/quoref_test.py
allennlp-models-main
tests/rc/evaluations/__init__.py
import io from contextlib import redirect_stdout from allennlp_models.rc.tools.drop import _normalize_answer, get_metrics, evaluate_json class TestDropEvalNormalize: def test_number_parse(self): assert _normalize_answer("12.0") == _normalize_answer("12.0 ") assert _normalize_answer("12.0") == _n...
allennlp-models-main
tests/rc/evaluations/drop_test.py