Skip to content

Commit

Permalink
make reader decorators public s.t. we can potentially define readers …
Browse files Browse the repository at this point in the history
…elsewhere
  • Loading branch information
dirkweissenborn committed Oct 27, 2017
1 parent 6e95339 commit 89c26d2
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions jack/readers/implementations.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ def __reader(f):
return f


def __extractive_qa_reader(f):
def extractive_qa_reader(f):
__reader(f)
extractive_qa_readers.setdefault(f.__name__, f)
eval_hooks.setdefault(f.__name__, XQAEvalHook)
return f


def __nli_reader(f):
def nli_reader(f):
__reader(f)
nli_readers.setdefault(f.__name__, f)
eval_hooks.setdefault(f.__name__, ClassificationEvalHook)
return f


def __kbp_reader(f):
def kbp_reader(f):
from jack.util.hooks import KBPEvalHook
__reader(f)
kbp_readers.setdefault(f.__name__, f)
Expand Down Expand Up @@ -64,7 +64,7 @@ def create_shared_resources(resources_or_config: Union[dict, SharedResources] =
return SharedResources(config=resources_or_config)


@__extractive_qa_reader
@extractive_qa_reader
def fastqa_reader(resources_or_conf: Union[dict, SharedResources] = None):
"""Creates a FastQA reader instance (extractive qa model)."""
from jack.readers.extractive_qa.fastqa import FastQAModule
Expand All @@ -77,7 +77,7 @@ def fastqa_reader(resources_or_conf: Union[dict, SharedResources] = None):
return TFReader(shared_resources, input_module, model_module, output_module)


@__extractive_qa_reader
@extractive_qa_reader
def bidaf_reader(resources_or_conf: Union[dict, SharedResources] = None):
"""Creates a FastQA model as described in https://arxiv.org/abs/1703.04816 (extractive qa model)."""
from jack.readers.extractive_qa.shared import XQAInputModule, XQAOutputModule
Expand All @@ -90,7 +90,7 @@ def bidaf_reader(resources_or_conf: Union[dict, SharedResources] = None):
return TFReader(shared_resources, input_module, model_module, output_module)


@__extractive_qa_reader
@extractive_qa_reader
def cbow_xqa_reader(resources_or_conf: Union[dict, SharedResources] = None):
"""Creates a CBow QA model as described in https://arxiv.org/abs/1703.04816. """
from jack.readers.extractive_qa.cbow import CbowXQAInputModule
Expand All @@ -104,7 +104,7 @@ def cbow_xqa_reader(resources_or_conf: Union[dict, SharedResources] = None):
return TFReader(shared_resources, input_module, model_module, output_module)


@__nli_reader
@nli_reader
def cbilstm_snli_reader(resources_or_conf: Union[dict, SharedResources] = None):
"""
Creates a SNLI reader instance (multiple choice qa model).
Expand All @@ -123,7 +123,7 @@ def cbilstm_snli_reader(resources_or_conf: Union[dict, SharedResources] = None):
return TFReader(shared_resources, input_module, model_module, output_module)


@__nli_reader
@nli_reader
def dam_snli_reader(resources_or_conf: Union[dict, SharedResources] = None):
"""Creates a SNLI reader instance (multiple choice qa model).
Expand All @@ -142,7 +142,7 @@ def dam_snli_reader(resources_or_conf: Union[dict, SharedResources] = None):
return TFReader(shared_resources, input_module, model_module, output_module)


@__nli_reader
@nli_reader
def esim_snli_reader(resources_or_conf: Union[dict, SharedResources] = None):
"""Creates a SNLI reader instance (multiple choice qa model).
Expand All @@ -161,7 +161,7 @@ def esim_snli_reader(resources_or_conf: Union[dict, SharedResources] = None):
return TFReader(shared_resources, input_module, model_module, output_module)


@__kbp_reader
@kbp_reader
def modelf_reader(resources_or_conf: Union[dict, SharedResources] = None):
"""Creates a knowledge_base_population model F."""
from jack.readers.knowledge_base_population.model_f import ModelFInputModule, ModelFModelModule, ModelFOutputModule
Expand All @@ -172,7 +172,7 @@ def modelf_reader(resources_or_conf: Union[dict, SharedResources] = None):
return TFReader(shared_resources, input_module, model_module, output_module)


@__kbp_reader
@kbp_reader
def distmult_reader(resources_or_conf: Union[dict, SharedResources] = None):
"""Creates a knowledge_base_population DistMult model."""
from jack.readers.knowledge_base_population.models import KnowledgeGraphEmbeddingInputModule, \
Expand All @@ -185,7 +185,7 @@ def distmult_reader(resources_or_conf: Union[dict, SharedResources] = None):
return TFReader(shared_resources, input_module, model_module, output_module)


@__kbp_reader
@kbp_reader
def complex_reader(resources_or_conf: Union[dict, SharedResources] = None):
""" Creates a knowledge_base_population Complex model."""
from jack.readers.knowledge_base_population.models import KnowledgeGraphEmbeddingInputModule, \
Expand All @@ -198,7 +198,7 @@ def complex_reader(resources_or_conf: Union[dict, SharedResources] = None):
return TFReader(shared_resources, input_module, model_module, output_module)


@__kbp_reader
@kbp_reader
def transe_reader(resources_or_conf: Union[dict, SharedResources] = None):
""" Creates a knowledge_base_population TransE model."""
from jack.readers.knowledge_base_population.models import KnowledgeGraphEmbeddingInputModule, \
Expand Down

0 comments on commit 89c26d2

Please sign in to comment.