Esempio n. 1
0
 def test_add_entry_value_none(self):
     key = "test"
     value = None
     list_entries = [{"str": key}]
     vocabulary = Vocabulary()
     vocabulary.add_entry(key, value)
     self.assertEqual(list_entries, vocabulary.temp_vocabulary['entries'])
Esempio n. 2
0
 def test_add_entry(self):
     key = "New York"
     value = "Knicks"
     list_entries = [{"str": key, "category": value}]
     vocabulary = Vocabulary()
     vocabulary.add_entry(key, value)
     self.assertEqual(list_entries, vocabulary.temp_vocabulary['entries'])
Esempio n. 3
0
 def test_create_input_stream_none(self, con):
     name = "some name"
     some_dict = {
         "id": "some value",
         'name': 'some name',
         'entries': [{
             'str': 'some entry'
         }]
     }
     some_entry = "some entry"
     voc = Vocabulary()
     voc.name(name)
     voc.add_entry(some_entry)
     response = Mock()
     response.json.return_value = some_dict
     con.return_value = response
     res = voc.create()
     self.assertEqual(str(res), str(some_dict))
Esempio n. 4
0
 def test_update(self, con):
     some_id = "some id"
     some_name = 'some name'
     some_key = 'some key'
     some_dict = {
         "id": None,
         'name': 'some name',
         'entries': [{
             'str': 'some entry'
         }]
     }
     voc = Vocabulary()
     voc.name(some_name)
     voc.add_entry(some_key)
     response = Mock()
     response.json.return_value = some_dict
     con.return_value = response
     res = voc.update(some_id)
     self.assertEqual(str(res), str(some_dict))
Esempio n. 5
0
 def test_create_input_stream(self, con):
     name = "some name"
     some_tsv_file = 'test.tsv'
     with open(some_tsv_file, "w") as f:
         f.write("Delete me!")
     some_dict = {
         "id": "some value",
         'name': 'some name',
         'entries': [{
             'str': 'some entry'
         }]
     }
     some_entry = "some entry"
     voc = Vocabulary()
     voc.name(name)
     voc.add_entry(some_entry)
     voc.source(some_tsv_file)
     response = Mock()
     response.json.return_value = some_dict
     con.return_value = response
     res = voc.create()
     self.assertEqual(str(res), str(some_dict))
     os.remove("test.tsv")
from qtcurate.result import Result

API_KEY = "YOUR-API-KEY"
DOCUMENT = "resources/sample.pdf"

# Initialise with api key
Qt.init(API_KEY)

# 1- Upload the sample document for processing
list_of_documents = []
document = Document()
doc = document.create(DOCUMENT)
list_of_documents.append(doc)
# 2- Create vocabulary
vocabulary = Vocabulary()
vocabulary.add_entry("Industrials")
vocabulary.add_entry("Quasi-Governments")
vocabulary.add_entry("Governments")
vocabulary.name("Allocations (%)").create()

# 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)
Esempio n. 7
0
 def test_add_entry_value_type(self):
     key = "test"
     value = ["Knicks"]
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.add_entry(key, value)
Esempio n. 8
0
from qtcurate.vocabulary import Vocabulary
from qtcurate.qt import Qt

API_KEY = "YOUR-API-KEY"
FILE_NAME = "resources/revenue.tsv"

# Initialise with api key
Qt.init(API_KEY)

vocabulary = Vocabulary()

# Create entries of vocabulary
vocabulary.add_entry("Apple Inc.", "AAPL")
vocabulary.add_entry("Amazon.com", "AMZN")
vocabulary.entries({"str": "Alphabet Inc.", "category": "GOOG"})

# Create Vocabulary
try:
    vocabulary.name("some name").add_entry("Apple Inc.", "AAPL").create()
except Exception as e:
    print(e)

# 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)