tweebo_parser package¶
Submodules¶
tweebo_parser.api module¶
Module contains the following class:
-
class
tweebo_parser.api.
API
(hostname='0.0.0.0', port=8000, retries=10, log_errors=False)[source]¶ Bases:
object
Allows easy connection and requests to the TweeboParse API server. TweeboParse is a Twitter specific dependency parser.
Attributes:
- hostname – The IP address of the TweeboParser API server.
- port – The Port that the TweeboParser API server is attached to.
- retries – Number of times to retry json decoding the returned data.
- log_errors – Whether to log errors or not. If this is True it logs errors under tweebo_log file within your temp_dir
-
__init__
(hostname='0.0.0.0', port=8000, retries=10, log_errors=False)[source]¶ Parameters: - hostname (
str
) – The IP address of the TweeboParser API server. - port (
int
) – The Port that the TweeboParser API server is attached to. - retries (
int
) – Number of times to retry json decoding the returned data.
Return type: None
- hostname (
-
log_error
(text)[source]¶ Given some error text it will log the text if self.log_errors is True
Parameters: text ( str
) – Error text to logReturn type: None
-
parse_conll
(texts, retry_count=0)[source]¶ Processes the texts using TweeboParse and returns them in CoNLL format.
Parameters: - texts (
List
[str
]) – The List of Strings to be processed by TweeboParse. - retry_count (
int
) – The number of times it has retried for. Default 0 does not require setting, main purpose is for recursion.
Return type: List
[str
]Returns: A list of CoNLL formated strings.
Raises: ServerError – Caused when the server is not running.
- :raises
requests.exceptions.HTTPError
: Caused when the - input texts is not formated correctly e.g. When you give it a String not a list of Strings.
- :raises
json.JSONDecodeError
: Caused if after self.retries - attempts to parse the data it cannot decode the data.
Example: - texts (
-
parse_stanford
(texts, retry_count=0)[source]¶ Processes the texts using TweeboParse and returns them in a Stanford styled format (as in the same format as the json return of the Stanford CoreNLP server dependency parser).
Parameters: - texts (
List
[str
]) – The List of Strings to be processed by TweeboParse. - retry_count (
int
) – The number of times it has retried for. Default 0 does not require setting, main purpose is for recursion.
Return type: List
[Dict
[str
,Union
[str
,int
]]]Returns: A list of dicts.
Raises: ServerError – Caused when the server is not running.
- :raises
requests.exceptions.HTTPError
: Caused when the - input texts is not formated correctly e.g. When you give it a String not a list of Strings.
- :raises
json.JSONDecodeError
: Caused if after self.retries - attempts to parse the data it cannot decode the data.
Example: - ::
- from tweebo_parser import API tweebo_api = API() text_data = [‘hello how are you’, ‘Where are we going’] result = tweebo_api.parse_stanford(text_data) print(result) [{}]
- texts (