Example #1
0
 def test_delete_false(self, con):
     some_id = 'some id'
     voc = Vocabulary()
     response = Mock()
     response.status_code = 200
     response.ok = False
     con.return_value = response
     res = voc.delete(some_id)
     self.assertEqual(res, False)
# 3- Creator Extractor - Regex must have 1 capturing group
extractor = Extractor()
extractor.set_vocabulary(vocabulary.get_id())
extractor.set_validator("^ +(\\d[\\d\\.\\,]+\\d)")
extractor.set_type(Type.DOUBLE)

# 4- Run
model = Model()
model.set_description("test data process")
model.add_extractor(extractor)
model.with_documents(list_of_documents)
model.create()

# 5- Wait to finish
model.wait_for_completion()

# 6- Export Field results
result = Result(model.get_id())
# print(result.read())
for item in result.read():
    field_value = item.get_values()[0]
    print(f"{item.get_str()} -> {field_value.get_str()}")

# 7- Export raw results to XLSX
result.result_xlsx_exporter("sample.xlsx")

# 8- Clean up
vocabulary.delete(vocabulary.get_id())
model.delete(model.get_id())
Example #3
0
 def test_delete_arg(self):
     vocabulary_id = 123
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.delete(vocabulary_id)
Example #4
0
# Fetch from current object
print("Fetch vocabulary")
print(vocabulary.fetch(vocabulary.get_id()))

# Create list of vocabularies from tsv file
print("Create list of the vocabularies from TSV file")
tsv_voc = Vocabulary()
tsv_voc.name("revenue")
tsv_voc.source(FILE_NAME)
try:
    tsv_voc.create()
except Exception as e:
    print(e)
print(tsv_voc)

# Update vocabulary, name and entries are mandatory options
print("Update vocabulary")
vocabulary.add_entry("Lenovo", "Thinkpad")
vocabulary.name("updated name")
print(vocabulary.get_id())
vocabulary.update(vocabulary.get_id())
print(vocabulary)

# List all existing vocabularies
print("List all vocabularies")
print(vocabulary.read())

# Delete vocabulary
print("Is vocabulary deleted?")
print(vocabulary.delete(vocabulary.get_id()))