cengal.text_processing.brackets_processing.versions.v_0.brackets
Module Docstring Docstrings: http://www.python.org/dev/peps/pep-0257/
1#!/usr/bin/env python 2# coding=utf-8 3 4# Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space> 5# 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17 18 19""" 20Module Docstring 21Docstrings: http://www.python.org/dev/peps/pep-0257/ 22""" 23 24 25__author__ = "ButenkoMS <gtalk@butenkoms.space>" 26__copyright__ = "Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>" 27__credits__ = ["ButenkoMS <gtalk@butenkoms.space>", ] 28__license__ = "Apache License, Version 2.0" 29__version__ = "4.4.1" 30__maintainer__ = "ButenkoMS <gtalk@butenkoms.space>" 31__email__ = "gtalk@butenkoms.space" 32# __status__ = "Prototype" 33__status__ = "Development" 34# __status__ = "Production" 35 36 37__all__ = ['Bracket', 'BracketPair', 'BracketsList', 'BracketAbsentType'] 38 39 40from enum import Enum 41from typing import Optional, Union, List 42from cengal.text_processing.text_processing import Text 43 44 45class BracketAbsentType(Enum): 46 out_of_data_bounds = 0 47 out_of_accessible_data_bounds = 1 48 49 50class BracketType(Enum): 51 absent = 0 52 text = 1 53 54 55_BRACKET_TYPE_ABSENT = 0 56_BRACKET_TYPE_TEXT = 1 57 58 59class WrongBracketId(Exception): 60 pass 61 62 63class Bracket: 64 def __init__(self, bracket_id: Union[Text, BracketAbsentType]): 65 self.bracket_id: Union[Text, BracketAbsentType] = bracket_id 66 if isinstance(bracket_id, BracketAbsentType): 67 self._type = _BRACKET_TYPE_ABSENT 68 else: 69 self._type = _BRACKET_TYPE_TEXT 70 71 def text(self) -> bool: 72 return _BRACKET_TYPE_TEXT == self._type 73 74 def absent(self) -> bool: 75 return _BRACKET_TYPE_ABSENT == self._type 76 77 78BracketsList = List[Bracket] 79 80 81class BracketPair: 82 def __init__(self, left: BracketsList, right: BracketsList): 83 self.left = left 84 self.right = right
class
Bracket:
64class Bracket: 65 def __init__(self, bracket_id: Union[Text, BracketAbsentType]): 66 self.bracket_id: Union[Text, BracketAbsentType] = bracket_id 67 if isinstance(bracket_id, BracketAbsentType): 68 self._type = _BRACKET_TYPE_ABSENT 69 else: 70 self._type = _BRACKET_TYPE_TEXT 71 72 def text(self) -> bool: 73 return _BRACKET_TYPE_TEXT == self._type 74 75 def absent(self) -> bool: 76 return _BRACKET_TYPE_ABSENT == self._type
Bracket( bracket_id: Union[bytes, bytearray, str, BracketAbsentType])
bracket_id: Union[bytes, bytearray, str, BracketAbsentType]
class
BracketPair:
82class BracketPair: 83 def __init__(self, left: BracketsList, right: BracketsList): 84 self.left = left 85 self.right = right
BracketsList =
typing.List[Bracket]
class
BracketAbsentType(enum.Enum):
An enumeration.
out_of_data_bounds =
<BracketAbsentType.out_of_data_bounds: 0>
out_of_accessible_data_bounds =
<BracketAbsentType.out_of_accessible_data_bounds: 1>
Inherited Members
- enum.Enum
- name
- value