Completed
Branch master (db5e7a)
by Osma
09:07 queued 05:09
created

HTTPBackend._analyze()   A

Complexity

Conditions 3

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
1
"""HTTP/REST client backend that makes calls to a web service
2
and returns the results"""
3
4
5
import requests
6
from annif.hit import AnalysisHit
7
from . import backend
8
9
10
class HTTPBackend(backend.AnnifBackend):
1 ignored issue
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
11
    name = "http"
12
13
    def _analyze(self, text, params):
14
        data = {'text': text, 'project': params['project']}
15
        req = requests.post(params['endpoint'], data=data)
16
        return [AnalysisHit(h['uri'], h['label'], h['score'])
17
                for h in req.json()
18
                if h['score'] > 0.0]
19