示例#1
0
    def delete(self, model_id: str) -> bool:
        """Delete data container"""

        if not isinstance(model_id, str):
            raise QtArgumentError("Argument type error: String is expected as model_id")
        res = connect("delete", f"{self.url}search/{model_id}", self.headers)
        return res.ok
示例#2
0
    def with_model(self, model_id: str) -> Job:
        """Add model to Job"""

        if isinstance(model_id, str):
            self.model_id = model_id
        else:
            raise QtArgumentError("Argument type error: Expected string as model ID")
        return self
示例#3
0
    def exclude_utt_without_entities(self, value: bool) -> Model:
        """Set exclude utt for mining data, this is optional parameter"""

        if isinstance(value, bool):
            self.temp_dictionary[exclude_utt] = value
        else:
            raise QtArgumentError("Argument type error: Boolean is expected as exclude utt without entities")
        return self
示例#4
0
    def set_workers(self, value: int) -> Model:
        """Set workers"""

        if isinstance(value, int):
            self.temp_dictionary[num_workers] = value
        else:
            raise QtArgumentError("Argument type error: Integer is expected as num_workers")
        return self
示例#5
0
    def with_documents(self, list_of_files: List) -> Model:
        """Create a list of existing files"""

        if isinstance(list_of_files, list):
            self.temp_dictionary[tag_files] = list_of_files
        else:
            raise QtArgumentError("Argument type error: Expected list of file IDs")
        return self
示例#6
0
    def set_id(self, uuid: str) -> None:
        """Set document id"""

        if isinstance(uuid, str):
            self.id = uuid
        else:
            raise QtArgumentError(
                "Argument type error: String is expected as uuid")
示例#7
0
    def set_chunk(self, value: ChunkMode) -> Model:
        """Set chunk mode"""

        if isinstance(value, ChunkMode):
            self.temp_dictionary[chunk] = value.value
        else:
            raise QtArgumentError("Argument type error: ChunkMode is expected as value")
        return self
示例#8
0
    def set_mode(self, mode: Mode) -> None:
        """Set mode"""

        if isinstance(mode, Mode):
            self.mode = mode
        else:
            raise QtArgumentError(
                "Argument type error: Mode is expected as mode")
示例#9
0
    def update(self, model_id: str, update_files: List) -> Model:
        """ Update model where model_id is existing ID"""

        self.headers["Content-Type"] = "application/json"
        if not isinstance(model_id, str):
            raise QtArgumentError("Argument type error: String is expected as model_id")
        if not isinstance(update_files, List):
            raise QtArgumentError("Argument type error: List is expected as update file")
        else:
            self.clear()
            data = {tag_files: update_files}
        res = connect("post", f"{self.url}search/update/{model_id}", self.headers, "data", json.dumps(data))
        result = res.json()
        del self.headers['Content-Type']
        self.id = model_id
        self.set_returned_data(result)
        return self
示例#10
0
    def set_description(self, title: str) -> Model:
        """Create title for model"""

        if isinstance(title, str):
            self.temp_dictionary[description] = title
        else:
            raise QtArgumentError("Argument type error: String is expected as description")
        return self
示例#11
0
    def set_id(self, model_id: str) -> Model:
        """Set model id"""

        if isinstance(model_id, str):
            self.id = model_id
        else:
            raise QtArgumentError("Argument type error: String is expected as model_id")
        return self
示例#12
0
    def set_stop_word_list(self, stop_word_list: List) -> Extractor:
        """ Set stop word list"""

        if isinstance(stop_word_list, list):
            self.stop_word_list = stop_word_list
        else:
            raise QtArgumentError(
                "Argument type error: List is expected as stop_word_list")
        return self
示例#13
0
    def set_type(self, data_type: Type) -> Extractor:
        """Set data type"""

        if isinstance(data_type, Type):
            self.type = data_type
        else:
            raise QtArgumentError(
                "Argument type error: String is expected as DataType")
        return self
示例#14
0
    def set_source(self, source_value: str) -> Field:
        """Set source in Field"""

        if isinstance(source_value, str):
            self.source = source_value
        else:
            raise QtArgumentError(
                "Argument type error: String is expected as source")
        return self
示例#15
0
    def set_start(self, pos_start: Optional[int]) -> Position:
        """ Set start position"""

        if isinstance(pos_start, (int, NoneType)):
            self.start = pos_start
        else:
            raise QtArgumentError(
                "Argument type error: Int is expected as pos_start")
        return self
示例#16
0
    def set_str(self, str_val: Optional[str]) -> FieldValue:
        """Set str in FieldValue"""

        if isinstance(str_val, (str, NoneType)):
            self.str_value = str_val
        else:
            raise QtArgumentError(
                "Argument type error: String is expected as str_val")
        return self
示例#17
0
    def set_page_num(self, page_num: Optional[int]) -> Position:
        """Set page number position"""

        if isinstance(page_num, (int, NoneType)):
            self.page_num = page_num
        else:
            raise QtArgumentError(
                "Argument type error: Int is expected as pos_line")
        return self
示例#18
0
    def set_line(self, pos_line: Optional[int]) -> Position:
        """Set line position"""

        if isinstance(pos_line, (int, NoneType)):
            self.line = pos_line
        else:
            raise QtArgumentError(
                "Argument type error: Int is expected as pos_line")
        return self
示例#19
0
    def set_end(self, pos_end: Optional[int]) -> Position:
        """ Set end position"""

        if isinstance(pos_end, (int, NoneType)):
            self.end = pos_end
        else:
            raise QtArgumentError(
                "Argument type error: Int is expected as pos_end")
        return self
示例#20
0
    def set_vocabulary(self, vocabulary: str) -> Extractor:
        """Set vocabulary id"""

        if isinstance(vocabulary, str):
            self.vocab_id = vocabulary
        else:
            raise QtArgumentError(
                "Argument type error: String is expected as vocab_id")
        return self
示例#21
0
    def set_vocab_id(self, voc_id: Optional[str]) -> Field:
        """Set vocabulary id"""

        if isinstance(voc_id, (str, NoneType)):
            self.vocab_id = voc_id
        else:
            raise QtArgumentError(
                "Argument type error: String is expected as voc_id")
        return self
示例#22
0
    def set_vocab_name(self, name: Optional[str]) -> Field:
        """Set vocabulary name"""

        if isinstance(name, (str, NoneType)):
            self.vocab_name = name
        else:
            raise QtArgumentError(
                "Argument type error: String is expected as name")
        return self
示例#23
0
    def set_position(self, position: Optional[Position]) -> Field:
        """Set position"""

        if isinstance(position, (Position, NoneType)):
            self.position = position
        else:
            raise QtArgumentError(
                "Argument type error: Position is expected as position")
        return self
示例#24
0
    def set_type(self, type_value: Optional[str]) -> Field:
        """Set type in Field"""

        if isinstance(type_value, (str, NoneType)):
            self.type = type_value
        else:
            raise QtArgumentError(
                "Argument type error: String is expected as type_value")
        return self
示例#25
0
    def set_category(self, cat: Optional[str]) -> Field:
        """Set category"""

        if isinstance(cat, (str, NoneType)):
            self.category = cat
        else:
            raise QtArgumentError(
                "Argument type error: String is expected as cat")
        return self
示例#26
0
    def set_between_values(self, between_values: str) -> Extractor:
        """Set between values"""

        if isinstance(between_values, str):
            self.between_values = between_values
        else:
            raise QtArgumentError(
                "Argument type error: String is expected as between_values")
        return self
示例#27
0
    def set_values(self, val: Optional[List]) -> Field:
        """Set values in Field"""

        if isinstance(val, (list, NoneType)):
            self.values = val
        else:
            raise QtArgumentError(
                "Argument type error: List is expected as val")
        return self
示例#28
0
    def set_synonym_list(self, synonym_list: List) -> Extractor:
        """Set synonym list"""

        if isinstance(synonym_list, list):
            self.synonym_list = synonym_list
        else:
            raise QtArgumentError(
                "Argument type error: List is expected as synonym_list")

        return self
示例#29
0
 def progress(self, job_id: str = None) -> Dict:
     """Show progress for submitted for job"""
     url_path = "progress"
     if job_id is not None:
         if isinstance(job_id, str):
             url_path = f"{url_path}/{job_id}"
         else:
             raise QtArgumentError("Expected string")
     res = connect("get", f"{self.url}search/{url_path}", self.headers)
     return res.json()
示例#30
0
    def set_validator(self, validator: str) -> Extractor:
        """Set validator"""

        if isinstance(validator, str):
            self.validator = validator
            self.vocab_value_type = "REGEX"
        else:
            raise QtArgumentError(
                "Argument type error: String is expected as validator")
        return self