python_code
stringlengths
0
187k
repo_name
stringlengths
8
46
file_path
stringlengths
6
135
import argparse import json from utils.file_utils import TsvIO from utils.file_utils import read_lines import pandas as pd def jsonl_to_tsv(jsonl_file, output_file, sep): records = [json.loads(line) for line in read_lines(jsonl_file)] if sep == "\t": TsvIO.write(records, filename=output_file, schema...
abductive-commonsense-reasoning-master
utils/jsonl_to_tsv.py
abductive-commonsense-reasoning-master
utils/__init__.py
from typing import List import json import gzip import csv def write_items(items: List[str], output_file): with open(output_file, 'w') as f: for item in items: f.write(str(item) + "\n") f.close() def read_lines(input_file: str) -> List[str]: lines = [] with open(input_file, "rb")...
abductive-commonsense-reasoning-master
utils/file_utils.py
cartography-main
cartography/__init__.py
""" Utilities for data handling. """ import json import logging import os import pandas as pd import shutil from typing import Dict from cartography.data_utils_glue import read_glue_tsv logger = logging.getLogger(__name__) def read_data(file_path: str, task_name: str, guid_as_int: bool ...
cartography-main
cartography/data_utils.py
import logging import random import re import tqdm logger = logging.getLogger(__name__) def convert_string_to_unique_number(string: str) -> int: """ Hack to convert SNLI ID into a unique integer ID, for tensorizing. """ id_map = {'e': '0', 'c': '1', 'n': '2'} # SNLI-specific hacks. if string.startswith(...
cartography-main
cartography/data_utils_glue.py
from transformers.data.processors.glue import QnliProcessor class AdaptedQnliProcessor(QnliProcessor): def get_examples(self, data_file, set_type): return self._create_examples(self._read_tsv(data_file), set_type=set_type)
cartography-main
cartography/classification/qnli_utils.py
import json import os class Params: """ All configuration required for running glue using transformers. """ def __init__(self, MODEL_CLASSES, ALL_MODELS, processors, configs): ### Required parameters # Directory where task data resides. self.data_dir : str = configs["data_dir"] # In...
cartography-main
cartography/classification/params.py
from torch.nn import CrossEntropyLoss, MSELoss from transformers import (BertForMultipleChoice, BertForSequenceClassification, RobertaForMultipleChoice, RobertaForSequenceClassification) class AdaptedRobertaForSequenceClassification(Robert...
cartography-main
cartography/classification/models.py
import argparse import logging import numpy as np import os from collections import defaultdict from sklearn.metrics import matthews_corrcoef from cartography.data_utils_glue import read_glue_tsv, convert_string_to_unique_number logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", le...
cartography-main
cartography/classification/diagnostics_evaluation.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
cartography-main
cartography/classification/run_glue.py
from transformers.data.processors.glue import MnliProcessor, MnliMismatchedProcessor class AdaptedMnliProcessor(MnliProcessor): def get_examples(self, data_file, set_type): return self._create_examples(self._read_tsv(data_file), set_type=set_type) class AdaptedMnliMismatchedProcessor(MnliMismatchedProcessor)...
cartography-main
cartography/classification/mnli_utils.py
cartography-main
cartography/classification/__init__.py
import logging import os from transformers import glue_compute_metrics from transformers import glue_convert_examples_to_features as convert_examples_to_features from transformers import glue_output_modes from transformers import glue_processors from transformers.data.processors.glue import MnliMismatchedProcessor fr...
cartography-main
cartography/classification/glue_utils.py
""" Utils for Multiple Choice Classification (for WinoGrande). """ import logging import tqdm from typing import List from transformers import PreTrainedTokenizer logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", level=logging.INFO ) logger = logging.getLogger(__name__) class MC...
cartography-main
cartography/classification/multiple_choice_utils.py
""" Scripts to handle the Winogrande task. """ import json import logging import os import tqdm from transformers.data.processors.utils import DataProcessor from cartography.classification.multiple_choice_utils import MCInputExample from cartography.data_utils import read_data class WinograndeProcessor(DataProcesso...
cartography-main
cartography/classification/winogrande_utils.py
import os from transformers.data.processors.utils import DataProcessor, InputExample class SNLIProcessor(DataProcessor): """Processor for the SNLI data set (GLUE version).""" def get_labels(self): return ["entailment", "neutral", "contradiction"] def _create_examples(self, lines, set_type): ...
cartography-main
cartography/classification/snli_utils.py
import json import logging import numpy as np import os import pandas as pd import tqdm from typing import List logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", level=logging.INFO ) logger = logging.getLogger(__name__) def log_training_dynamics(output_dir: os.path, ...
cartography-main
cartography/selection/selection_utils.py
""" Randomly sample dataset examples for a data selection baseline. """ import argparse import logging import os import pandas as pd logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", level=logging.INFO ) logger = logging.getLogger(__name__) from cartography.data_utils import read_d...
cartography-main
cartography/selection/random_filtering.py
""" Filtering and dataset mapping methods based on training dynamics. By default, this module reads training dynamics from a given trained model and computes the metrics---confidence, variability, correctness, as well as baseline metrics of forgetfulness and threshold closeness for each instance in the training data. I...
cartography-main
cartography/selection/train_dy_filtering.py
cartography-main
cartography/selection/__init__.py
from invoke import task @task def set_version(c, version): """Writes the version upon a release.""" for filename in ["setup.py", "ai2thor_colab/__init__.py"]: with open(filename, "r") as f: file = f.read() file = file.replace("<REPLACE_WITH_VERSION>", version) with open(fil...
ai2thor-colab-main
tasks.py
from setuptools import setup version = "<REPLACE_WITH_VERSION>" with open("README.md", encoding="utf-8") as f: long_description = f.read() setup( name="ai2thor_colab", packages=["ai2thor_colab"], version=version, license="Apache 2.0", description="Utility functions for using AI2-THOR with Goo...
ai2thor-colab-main
setup.py
from IPython.display import HTML, display import sys from moviepy.editor import ImageSequenceClip from typing import Sequence import numpy as np import os from typing import Optional import ai2thor.server from typing import Union from PIL import Image import matplotlib.pyplot as plt __version__ = "<REPLACE_WITH_VERS...
ai2thor-colab-main
ai2thor_colab/__init__.py
allennlp-demo-main
api/allennlp_demo/__init__.py
allennlp-demo-main
api/allennlp_demo/glove_sentiment_analysis/__init__.py
import os from allennlp_demo.common import config, http class GloveSentimentAnalysisModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = GloveSentime...
allennlp-demo-main
api/allennlp_demo/glove_sentiment_analysis/api.py
from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.glove_sentiment_analysis.api import GloveSentimentAnalysisModelEndpoint class TestGloveSentimentAnalysisModelEndpoint(ModelEndpointTestCase): endpoint = GloveSentimentAnalysisModelEndpoint() predict_input = {"sentence": "a very ...
allennlp-demo-main
api/allennlp_demo/glove_sentiment_analysis/test_api.py
allennlp-demo-main
api/allennlp_demo/constituency_parser/__init__.py
import os from allennlp_demo.common import config, http class ConstituencyParserModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = ConstituencyPars...
allennlp-demo-main
api/allennlp_demo/constituency_parser/api.py
from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.constituency_parser.api import ConstituencyParserModelEndpoint class TestConstituencyParserModelEndpoint(ModelEndpointTestCase): endpoint = ConstituencyParserModelEndpoint() predict_input = {"sentence": "If I bring 10 dollars to...
allennlp-demo-main
api/allennlp_demo/constituency_parser/test_api.py
allennlp-demo-main
api/allennlp_demo/tasks/__init__.py
""" The tasks endpoint lists all demo tasks and some info about them. """ import logging import flask from allennlp_demo.common.logs import configure_logging from allennlp_models.pretrained import get_tasks logger = logging.getLogger(__name__) class TasksService(flask.Flask): def __init__(self, name: str = "tas...
allennlp-demo-main
api/allennlp_demo/tasks/api.py
from .api import TasksService def test_tasks(): app = TasksService() client = app.test_client() response = client.get("/") assert response.status_code == 200 assert len(response.json.items()) > 0
allennlp-demo-main
api/allennlp_demo/tasks/test_api.py
allennlp-demo-main
api/allennlp_demo/semantic_role_labeling/__init__.py
import os from allennlp_demo.common import config, http class SrlModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = SrlModelEndpoint() endpoint...
allennlp-demo-main
api/allennlp_demo/semantic_role_labeling/api.py
from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.semantic_role_labeling.api import SrlModelEndpoint class TestSrlModelEndpoint(ModelEndpointTestCase): endpoint = SrlModelEndpoint() predict_input = { "sentence": "Did Uriah honestly think he could beat the game in under ...
allennlp-demo-main
api/allennlp_demo/semantic_role_labeling/test_api.py
allennlp-demo-main
api/allennlp_demo/dependency_parser/__init__.py
import os from allennlp_demo.common import config, http class DependencyParserModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = DependencyParserMo...
allennlp-demo-main
api/allennlp_demo/dependency_parser/api.py
from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.dependency_parser.api import DependencyParserModelEndpoint class TestDependencyParserModelEndpoint(ModelEndpointTestCase): endpoint = DependencyParserModelEndpoint() predict_input = {"sentence": "If I bring 10 dollars tomorrow, ...
allennlp-demo-main
api/allennlp_demo/dependency_parser/test_api.py
allennlp-demo-main
api/allennlp_demo/wikitables_parser/__init__.py
import os from allennlp_demo.common import config, http class WikitablesParserModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = WikitablesParserMo...
allennlp-demo-main
api/allennlp_demo/wikitables_parser/api.py
from allennlp_demo.wikitables_parser.api import WikitablesParserModelEndpoint from allennlp_demo.common.testing import ModelEndpointTestCase class TestWikitablesParserModelEndpoint(ModelEndpointTestCase): endpoint = WikitablesParserModelEndpoint() predict_input = { "table": "\n".join( [ ...
allennlp-demo-main
api/allennlp_demo/wikitables_parser/test_api.py
allennlp-demo-main
api/allennlp_demo/next_token_lm/__init__.py
import os import re from typing import Dict, Any from allennlp.interpret.attackers import Attacker, Hotflip from allennlp.predictors.predictor import JsonDict from overrides import overrides from allennlp_demo.common import config, http class NextTokenLmModelEndpoint(http.ModelEndpoint): # TODO: don't hardcode ...
allennlp-demo-main
api/allennlp_demo/next_token_lm/api.py
import pytest from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.next_token_lm.api import NextTokenLmModelEndpoint class TestNextTokenLmModelEndpoint(ModelEndpointTestCase): endpoint = NextTokenLmModelEndpoint() predict_input = {"sentence": "AlleNLP is a"} @pytest.mark.par...
allennlp-demo-main
api/allennlp_demo/next_token_lm/test_api.py
allennlp-demo-main
api/allennlp_demo/elmo_snli/__init__.py
import os from allennlp_demo.common import config, http class ElmoSnliModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = ElmoSnliModelEndpoint() ...
allennlp-demo-main
api/allennlp_demo/elmo_snli/api.py
from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.elmo_snli.api import ElmoSnliModelEndpoint class TestElmoSnliModelEndpoint(ModelEndpointTestCase): endpoint = ElmoSnliModelEndpoint() predict_input = { "hypothesis": "Two women are sitting on a blanket near some rocks ta...
allennlp-demo-main
api/allennlp_demo/elmo_snli/test_api.py
allennlp-demo-main
api/allennlp_demo/fine_grained_ner/__init__.py
import os from allennlp_demo.common import config, http class FineGrainedNerModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = FineGrainedNerModelE...
allennlp-demo-main
api/allennlp_demo/fine_grained_ner/api.py
from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.fine_grained_ner.api import FineGrainedNerModelEndpoint class TestFineGrainedNerModelEndpoint(ModelEndpointTestCase): endpoint = FineGrainedNerModelEndpoint() predict_input = { "sentence": "Did Uriah honestly think he co...
allennlp-demo-main
api/allennlp_demo/fine_grained_ner/test_api.py
allennlp-demo-main
api/allennlp_demo/naqanet/__init__.py
import os from allennlp_demo.common import config, http class NAQANetModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = NAQANetModelEndpoint() ...
allennlp-demo-main
api/allennlp_demo/naqanet/api.py
from overrides import overrides from allennlp_demo.common.testing import RcModelEndpointTestCase from allennlp_demo.naqanet.api import NAQANetModelEndpoint class TestNAQANetModelEndpoint(RcModelEndpointTestCase): endpoint = NAQANetModelEndpoint() @overrides def check_predict_result(self, result): ...
allennlp-demo-main
api/allennlp_demo/naqanet/test_api.py
allennlp-demo-main
api/allennlp_demo/adversarial_binary_gender_bias_mitigated_roberta_snli/__init__.py
import os from allennlp_demo.common import config, http class AdversarialBinaryGenderBiasMitigatedRobertaSnliModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": ...
allennlp-demo-main
api/allennlp_demo/adversarial_binary_gender_bias_mitigated_roberta_snli/api.py
from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.adversarial_binary_gender_bias_mitigated_roberta_snli.api import ( AdversarialBinaryGenderBiasMitigatedRobertaSnliModelEndpoint, ) class TestAdversarialBinaryGenderBiasMitigatedRobertaSnliModelEndpoint(ModelEndpointTestCase): en...
allennlp-demo-main
api/allennlp_demo/adversarial_binary_gender_bias_mitigated_roberta_snli/test_api.py
allennlp-demo-main
api/allennlp_demo/lerc/__init__.py
import os from allennlp.common.util import import_module_and_submodules from allennlp_demo.common import config, http class LERCModelEndpoint(http.ModelEndpoint): def __init__(self): import_module_and_submodules("lerc") c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.js...
allennlp-demo-main
api/allennlp_demo/lerc/api.py
import math from overrides import overrides from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.lerc.api import LERCModelEndpoint class TestLERCModelEndpoint(ModelEndpointTestCase): endpoint = LERCModelEndpoint() predict_input = { "context": "Robin wept in front of Skyl...
allennlp-demo-main
api/allennlp_demo/lerc/test_api.py
allennlp-demo-main
api/allennlp_demo/masked_lm/__init__.py
import os from typing import Dict from allennlp.interpret.attackers import Attacker, Hotflip from allennlp_demo.common import config, http class MaskedLmModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super(...
allennlp-demo-main
api/allennlp_demo/masked_lm/api.py
from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.masked_lm.api import MaskedLmModelEndpoint class TestMaskedLmModelEndpoint(ModelEndpointTestCase): endpoint = MaskedLmModelEndpoint() predict_input = {"sentence": "The doctor ran to the emergency room to see [MASK] patient."}
allennlp-demo-main
api/allennlp_demo/masked_lm/test_api.py
allennlp-demo-main
api/allennlp_demo/transformer_qa/__init__.py
import os from allennlp.common.util import JsonDict from allennlp_demo.common import config, http class TransformerQaModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) def predict(self,...
allennlp-demo-main
api/allennlp_demo/transformer_qa/api.py
from allennlp_demo.common.testing import RcModelEndpointTestCase from allennlp_demo.transformer_qa.api import TransformerQaModelEndpoint class TestTransformerQaModelEndpoint(RcModelEndpointTestCase): endpoint = TransformerQaModelEndpoint()
allennlp-demo-main
api/allennlp_demo/transformer_qa/test_api.py
allennlp-demo-main
api/allennlp_demo/named_entity_recognition/__init__.py
import os from allennlp_demo.common import config, http class NerModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = NerModelEndpoint() endpoint...
allennlp-demo-main
api/allennlp_demo/named_entity_recognition/api.py
from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.named_entity_recognition.api import NerModelEndpoint class TestNerModelEndpoint(ModelEndpointTestCase): endpoint = NerModelEndpoint() predict_input = { "sentence": "Did Uriah honestly think he could beat The Legend of Ze...
allennlp-demo-main
api/allennlp_demo/named_entity_recognition/test_api.py
allennlp-demo-main
api/allennlp_demo/roberta_mnli/__init__.py
import os from allennlp_demo.common import config, http class RobertaMnliModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = RobertaMnliModelEndpoin...
allennlp-demo-main
api/allennlp_demo/roberta_mnli/api.py
from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.roberta_mnli.api import RobertaMnliModelEndpoint class TestRobertaMnliModelEndpoint(ModelEndpointTestCase): endpoint = RobertaMnliModelEndpoint() predict_input = { "hypothesis": "Two women are sitting on a blanket near s...
allennlp-demo-main
api/allennlp_demo/roberta_mnli/test_api.py
allennlp-demo-main
api/allennlp_demo/bidaf/__init__.py
import os from allennlp_demo.common import config, http class BidafModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = BidafModelEndpoint() endp...
allennlp-demo-main
api/allennlp_demo/bidaf/api.py
from allennlp_demo.common.testing import RcModelEndpointTestCase from allennlp_demo.bidaf.api import BidafModelEndpoint class TestBidafModelEndpoint(RcModelEndpointTestCase): endpoint = BidafModelEndpoint()
allennlp-demo-main
api/allennlp_demo/bidaf/test_api.py
allennlp-demo-main
api/allennlp_demo/roberta_sentiment_analysis/__init__.py
import os from allennlp_demo.common import config, http class RobertaSentimentAnalysisModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = RobertaSen...
allennlp-demo-main
api/allennlp_demo/roberta_sentiment_analysis/api.py
from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.roberta_sentiment_analysis.api import RobertaSentimentAnalysisModelEndpoint class TestRobertaSentimentAnalysisModelEndpoint(ModelEndpointTestCase): endpoint = RobertaSentimentAnalysisModelEndpoint() predict_input = {"sentence": ...
allennlp-demo-main
api/allennlp_demo/roberta_sentiment_analysis/test_api.py
allennlp-demo-main
api/allennlp_demo/model_cards/__init__.py
import logging import flask from typing import Dict from allennlp_demo.common.logs import configure_logging from allennlp_models.pretrained import get_pretrained_models logger = logging.getLogger(__name__) class ModelCardsService(flask.Flask): def __init__(self, name: str = "model-cards"): super().__i...
allennlp-demo-main
api/allennlp_demo/model_cards/api.py
from .api import ModelCardsService def test_model_cards(): app = ModelCardsService() client = app.test_client() response = client.get("/") assert response.status_code == 200 assert len(response.json) > 0 bidaf = response.json.get("rc-bidaf") assert bidaf is not None assert bidaf.get("d...
allennlp-demo-main
api/allennlp_demo/model_cards/test_api.py
allennlp-demo-main
api/allennlp_demo/bidaf_elmo/__init__.py
import os from allennlp_demo.common import config, http class BidafElmoModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = BidafElmoModelEndpoint() ...
allennlp-demo-main
api/allennlp_demo/bidaf_elmo/api.py
from overrides import overrides import pytest from allennlp_demo.bidaf_elmo.api import BidafElmoModelEndpoint from allennlp_demo.common.testing import RcModelEndpointTestCase class TestBidafElmoModelEndpoint(RcModelEndpointTestCase): endpoint = BidafElmoModelEndpoint() @pytest.mark.skip("Takes too long") ...
allennlp-demo-main
api/allennlp_demo/bidaf_elmo/test_api.py
import json from dataclasses import dataclass, field from typing import Dict, Any, Optional, List from allennlp.predictors import Predictor VALID_ATTACKERS = ["hotflip", "input_reduction"] VALID_INTERPRETERS = ["simple_gradient", "smooth_gradient", "integrated_gradient"] @dataclass(frozen=True) class Model: ""...
allennlp-demo-main
api/allennlp_demo/common/config.py
allennlp-demo-main
api/allennlp_demo/common/__init__.py
import os import sys import json import logging import time from typing import Mapping from flask import Flask, request, Response, g from dataclasses import dataclass, asdict from typing import Optional @dataclass(frozen=True) class RequestLogEntry: status: int method: str path: str query: dict r...
allennlp-demo-main
api/allennlp_demo/common/logs.py
from functools import lru_cache from dataclasses import asdict import json from typing import Callable, Dict from flask import Flask, Request, Response, after_this_request, request, jsonify from allennlp.version import VERSION from allennlp.predictors.predictor import JsonDict from allennlp.interpret.saliency_interpre...
allennlp-demo-main
api/allennlp_demo/common/http.py
from overrides import overrides from allennlp_demo.common.http import ModelEndpoint from allennlp_demo.common.testing.model_endpoint_test_case import ModelEndpointTestCase class RcModelEndpointTestCase(ModelEndpointTestCase): """ Provides a solid set of test methods for RC models. Individual methods can be o...
allennlp-demo-main
api/allennlp_demo/common/testing/rc.py
from allennlp_demo.common.testing.model_endpoint_test_case import ModelEndpointTestCase from allennlp_demo.common.testing.rc import RcModelEndpointTestCase
allennlp-demo-main
api/allennlp_demo/common/testing/__init__.py
import os from pathlib import Path from typing import Optional, Any, Dict, List from flask.testing import FlaskClient from flask.wrappers import Response from allennlp_demo.common.http import ModelEndpoint from allennlp_demo.common.config import VALID_ATTACKERS, VALID_INTERPRETERS class ModelEndpointTestCase: "...
allennlp-demo-main
api/allennlp_demo/common/testing/model_endpoint_test_case.py
allennlp-demo-main
api/allennlp_demo/open_information_extraction/__init__.py
import os from allennlp_demo.common import config, http class OpenInformationExtractionModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = OpenInfor...
allennlp-demo-main
api/allennlp_demo/open_information_extraction/api.py
from allennlp_demo.common.testing import ModelEndpointTestCase from allennlp_demo.open_information_extraction.api import OpenInformationExtractionModelEndpoint class TestOpenInformationExtractionModelEndpoint(ModelEndpointTestCase): endpoint = OpenInformationExtractionModelEndpoint() predict_input = {"sentenc...
allennlp-demo-main
api/allennlp_demo/open_information_extraction/test_api.py
allennlp-demo-main
api/allennlp_demo/nlvr_parser/__init__.py
import os from allennlp_demo.common import config, http class NlvrParserModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = NlvrParserModelEndpoint(...
allennlp-demo-main
api/allennlp_demo/nlvr_parser/api.py
from allennlp_demo.nlvr_parser.api import NlvrParserModelEndpoint from allennlp_demo.common.testing import ModelEndpointTestCase class TestNlvrParserModelEndpoint(ModelEndpointTestCase): endpoint = NlvrParserModelEndpoint() predict_input = { "sentence": "there is exactly one yellow object touching the...
allennlp-demo-main
api/allennlp_demo/nlvr_parser/test_api.py
allennlp-demo-main
api/allennlp_demo/atis_parser/__init__.py
import os from allennlp_demo.common import config, http class AtisParserModelEndpoint(http.ModelEndpoint): def __init__(self): c = config.Model.from_file(os.path.join(os.path.dirname(__file__), "model.json")) super().__init__(c) if __name__ == "__main__": endpoint = AtisParserModelEndpoint(...
allennlp-demo-main
api/allennlp_demo/atis_parser/api.py