Fix print_answers (#1743)

* Fix a specific path of print_answers that was assuming answers are dictionaries

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Sara Zan 2021-11-15 09:50:09 +01:00 committed by GitHub
parent ea3abd305b
commit 09a462d756
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 28 deletions

View File

@ -2,7 +2,7 @@
# Module base # Module base
<a name="base.BaseDocumentClassifier"></a> <a name="base.BaseDocumentClassifier"></a>
## BaseDocumentClassifier Objects ## BaseDocumentClassifier
```python ```python
class BaseDocumentClassifier(BaseComponent) class BaseDocumentClassifier(BaseComponent)
@ -21,7 +21,7 @@ Wrapper method used to time functions.
# Module transformers # Module transformers
<a name="transformers.TransformersDocumentClassifier"></a> <a name="transformers.TransformersDocumentClassifier"></a>
## TransformersDocumentClassifier Objects ## TransformersDocumentClassifier
```python ```python
class TransformersDocumentClassifier(BaseDocumentClassifier) class TransformersDocumentClassifier(BaseDocumentClassifier)

View File

@ -2,7 +2,7 @@
# Module evaluator # Module evaluator
<a name="evaluator.EvalDocuments"></a> <a name="evaluator.EvalDocuments"></a>
## EvalDocuments Objects ## EvalDocuments
```python ```python
class EvalDocuments(BaseComponent) class EvalDocuments(BaseComponent)
@ -48,7 +48,7 @@ Run this node on one sample and its labels
Print the evaluation results Print the evaluation results
<a name="evaluator.EvalAnswers"></a> <a name="evaluator.EvalAnswers"></a>
## EvalAnswers Objects ## EvalAnswers
```python ```python
class EvalAnswers(BaseComponent) class EvalAnswers(BaseComponent)

View File

@ -2,7 +2,7 @@
# Module base # Module base
<a name="base.RootNode"></a> <a name="base.RootNode"></a>
## RootNode Objects ## RootNode
```python ```python
class RootNode(BaseComponent) class RootNode(BaseComponent)
@ -11,7 +11,7 @@ class RootNode(BaseComponent)
RootNode feeds inputs together with corresponding params to a Pipeline. RootNode feeds inputs together with corresponding params to a Pipeline.
<a name="base.BasePipeline"></a> <a name="base.BasePipeline"></a>
## BasePipeline Objects ## BasePipeline
```python ```python
class BasePipeline() class BasePipeline()
@ -72,7 +72,7 @@ Here's a sample configuration:
`_` sign must be used to specify nested hierarchical properties. `_` sign must be used to specify nested hierarchical properties.
<a name="base.Pipeline"></a> <a name="base.Pipeline"></a>
## Pipeline Objects ## Pipeline
```python ```python
class Pipeline(BasePipeline) class Pipeline(BasePipeline)
@ -268,7 +268,7 @@ Save a YAML configuration for the Pipeline that can be used with `Pipeline.load_
- `return_defaults`: whether to output parameters that have the default values. - `return_defaults`: whether to output parameters that have the default values.
<a name="base.RayPipeline"></a> <a name="base.RayPipeline"></a>
## RayPipeline Objects ## RayPipeline
```python ```python
class RayPipeline(Pipeline) class RayPipeline(Pipeline)
@ -369,7 +369,7 @@ Here's a sample configuration:
- `address`: The IP address for the Ray cluster. If set to None, a local Ray instance is started. - `address`: The IP address for the Ray cluster. If set to None, a local Ray instance is started.
<a name="base._RayDeploymentWrapper"></a> <a name="base._RayDeploymentWrapper"></a>
## \_RayDeploymentWrapper Objects ## \_RayDeploymentWrapper
```python ```python
class _RayDeploymentWrapper() class _RayDeploymentWrapper()
@ -410,7 +410,7 @@ Ray calls this method which is then re-directed to the corresponding component's
# Module standard\_pipelines # Module standard\_pipelines
<a name="standard_pipelines.BaseStandardPipeline"></a> <a name="standard_pipelines.BaseStandardPipeline"></a>
## BaseStandardPipeline Objects ## BaseStandardPipeline
```python ```python
class BaseStandardPipeline(ABC) class BaseStandardPipeline(ABC)
@ -482,7 +482,7 @@ Create a Graphviz visualization of the pipeline.
- `path`: the path to save the image. - `path`: the path to save the image.
<a name="standard_pipelines.ExtractiveQAPipeline"></a> <a name="standard_pipelines.ExtractiveQAPipeline"></a>
## ExtractiveQAPipeline Objects ## ExtractiveQAPipeline
```python ```python
class ExtractiveQAPipeline(BaseStandardPipeline) class ExtractiveQAPipeline(BaseStandardPipeline)
@ -521,7 +521,7 @@ Pipeline for Extractive Question Answering.
by this method under the key "_debug" by this method under the key "_debug"
<a name="standard_pipelines.DocumentSearchPipeline"></a> <a name="standard_pipelines.DocumentSearchPipeline"></a>
## DocumentSearchPipeline Objects ## DocumentSearchPipeline
```python ```python
class DocumentSearchPipeline(BaseStandardPipeline) class DocumentSearchPipeline(BaseStandardPipeline)
@ -558,7 +558,7 @@ Pipeline for semantic document search.
by this method under the key "_debug" by this method under the key "_debug"
<a name="standard_pipelines.GenerativeQAPipeline"></a> <a name="standard_pipelines.GenerativeQAPipeline"></a>
## GenerativeQAPipeline Objects ## GenerativeQAPipeline
```python ```python
class GenerativeQAPipeline(BaseStandardPipeline) class GenerativeQAPipeline(BaseStandardPipeline)
@ -597,7 +597,7 @@ Pipeline for Generative Question Answering.
by this method under the key "_debug" by this method under the key "_debug"
<a name="standard_pipelines.SearchSummarizationPipeline"></a> <a name="standard_pipelines.SearchSummarizationPipeline"></a>
## SearchSummarizationPipeline Objects ## SearchSummarizationPipeline
```python ```python
class SearchSummarizationPipeline(BaseStandardPipeline) class SearchSummarizationPipeline(BaseStandardPipeline)
@ -639,7 +639,7 @@ Pipeline that retrieves documents for a query and then summarizes those document
by this method under the key "_debug" by this method under the key "_debug"
<a name="standard_pipelines.FAQPipeline"></a> <a name="standard_pipelines.FAQPipeline"></a>
## FAQPipeline Objects ## FAQPipeline
```python ```python
class FAQPipeline(BaseStandardPipeline) class FAQPipeline(BaseStandardPipeline)
@ -676,7 +676,7 @@ Pipeline for finding similar FAQs using semantic document search.
by this method under the key "_debug" by this method under the key "_debug"
<a name="standard_pipelines.TranslationWrapperPipeline"></a> <a name="standard_pipelines.TranslationWrapperPipeline"></a>
## TranslationWrapperPipeline Objects ## TranslationWrapperPipeline
```python ```python
class TranslationWrapperPipeline(BaseStandardPipeline) class TranslationWrapperPipeline(BaseStandardPipeline)
@ -702,7 +702,7 @@ Wrap a given `pipeline` with the `input_translator` and `output_translator`.
Note that pipelines with split or merge nodes are currently not supported. Note that pipelines with split or merge nodes are currently not supported.
<a name="standard_pipelines.QuestionGenerationPipeline"></a> <a name="standard_pipelines.QuestionGenerationPipeline"></a>
## QuestionGenerationPipeline Objects ## QuestionGenerationPipeline
```python ```python
class QuestionGenerationPipeline(BaseStandardPipeline) class QuestionGenerationPipeline(BaseStandardPipeline)
@ -712,7 +712,7 @@ A simple pipeline that takes documents as input and generates
questions that it thinks can be answered by the documents. questions that it thinks can be answered by the documents.
<a name="standard_pipelines.RetrieverQuestionGenerationPipeline"></a> <a name="standard_pipelines.RetrieverQuestionGenerationPipeline"></a>
## RetrieverQuestionGenerationPipeline Objects ## RetrieverQuestionGenerationPipeline
```python ```python
class RetrieverQuestionGenerationPipeline(BaseStandardPipeline) class RetrieverQuestionGenerationPipeline(BaseStandardPipeline)
@ -722,7 +722,7 @@ A simple pipeline that takes a query as input, performs retrieval, and then gene
questions that it thinks can be answered by the retrieved documents. questions that it thinks can be answered by the retrieved documents.
<a name="standard_pipelines.QuestionAnswerGenerationPipeline"></a> <a name="standard_pipelines.QuestionAnswerGenerationPipeline"></a>
## QuestionAnswerGenerationPipeline Objects ## QuestionAnswerGenerationPipeline
```python ```python
class QuestionAnswerGenerationPipeline(BaseStandardPipeline) class QuestionAnswerGenerationPipeline(BaseStandardPipeline)
@ -732,7 +732,7 @@ This is a pipeline which takes a document as input, generates questions that the
this document, and then performs question answering of this questions using that single document. this document, and then performs question answering of this questions using that single document.
<a name="standard_pipelines.MostSimilarDocumentsPipeline"></a> <a name="standard_pipelines.MostSimilarDocumentsPipeline"></a>
## MostSimilarDocumentsPipeline Objects ## MostSimilarDocumentsPipeline
```python ```python
class MostSimilarDocumentsPipeline(BaseStandardPipeline) class MostSimilarDocumentsPipeline(BaseStandardPipeline)

View File

@ -2,7 +2,7 @@
# Module base # Module base
<a name="base.BaseQueryClassifier"></a> <a name="base.BaseQueryClassifier"></a>
## BaseQueryClassifier Objects ## BaseQueryClassifier
```python ```python
class BaseQueryClassifier(BaseComponent) class BaseQueryClassifier(BaseComponent)
@ -14,7 +14,7 @@ Abstract class for Query Classifiers
# Module sklearn # Module sklearn
<a name="sklearn.SklearnQueryClassifier"></a> <a name="sklearn.SklearnQueryClassifier"></a>
## SklearnQueryClassifier Objects ## SklearnQueryClassifier
```python ```python
class SklearnQueryClassifier(BaseQueryClassifier) class SklearnQueryClassifier(BaseQueryClassifier)
@ -81,7 +81,7 @@ queries or statement vs question queries.
# Module transformers # Module transformers
<a name="transformers.TransformersQueryClassifier"></a> <a name="transformers.TransformersQueryClassifier"></a>
## TransformersQueryClassifier Objects ## TransformersQueryClassifier
```python ```python
class TransformersQueryClassifier(BaseQueryClassifier) class TransformersQueryClassifier(BaseQueryClassifier)

View File

@ -2,7 +2,7 @@
# Module question\_generator # Module question\_generator
<a name="question_generator.QuestionGenerator"></a> <a name="question_generator.QuestionGenerator"></a>
## QuestionGenerator Objects ## QuestionGenerator
```python ```python
class QuestionGenerator(BaseComponent) class QuestionGenerator(BaseComponent)

View File

@ -2,7 +2,7 @@
# Module base # Module base
<a name="base.BaseRanker"></a> <a name="base.BaseRanker"></a>
## BaseRanker Objects ## BaseRanker
```python ```python
class BaseRanker(BaseComponent) class BaseRanker(BaseComponent)
@ -55,7 +55,7 @@ position in the ranking of documents the correct document is.
# Module sentence\_transformers # Module sentence\_transformers
<a name="sentence_transformers.SentenceTransformersRanker"></a> <a name="sentence_transformers.SentenceTransformersRanker"></a>
## SentenceTransformersRanker Objects ## SentenceTransformersRanker
```python ```python
class SentenceTransformersRanker(BaseRanker) class SentenceTransformersRanker(BaseRanker)

View File

@ -55,8 +55,8 @@ def print_answers(results: dict, details: str = "all", max_text_len: Optional[in
# Shorten long text fields # Shorten long text fields
if max_text_len is not None: if max_text_len is not None:
for ans in answers: for ans in answers:
if "context" in ans.keys() and len(ans["context"]) > 50: if getattr(ans, "context") and len(ans.context) > 50:
ans["context"] = ans["context"][:50] + "..." ans.context = ans.context[:50] + "..."
pp.pprint(filtered_answers) pp.pprint(filtered_answers)