Exemplo n.º 1
0
 def test_update_name(self):
     vocabulary_id = "string"
     entries = {"str": "str", "category": "category"}
     vocabulary = Vocabulary()
     vocabulary.entries(entries)
     with self.assertRaises(QtVocabularyError):
         vocabulary.update(vocabulary_id)
Exemplo n.º 2
0
 def test_entries_vocabulary_len_3(self):
     test_vocabulary = {
         "str": "str",
         "category": "category",
         "some_key": "some_value"
     }
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.entries(test_vocabulary)
Exemplo n.º 3
0
 def test_entries_category(self):
     test_vocabulary = {"str": "str"}
     vocabulary = Vocabulary()
     vocabulary.entries(test_vocabulary)
     self.assertEqual([test_vocabulary],
                      vocabulary.temp_vocabulary['entries'])
Exemplo n.º 4
0
 def test_entries_vocabulary_content_2(self):
     test_vocabulary = {"str": "str", "test": "category"}
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.entries(test_vocabulary)
Exemplo n.º 5
0
 def test_entries_vocabulary_len_0(self):
     test_vocabulary = {}
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.entries(test_vocabulary)
Exemplo n.º 6
0
 def test_entries_type(self):
     test_vocabulary = "string"
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.entries(test_vocabulary)
Exemplo n.º 7
0
 def test_create_miss_name(self):
     entries = {"str": "str", "category": "category"}
     vocabulary = Vocabulary()
     vocabulary.entries(entries)
     with self.assertRaises(QtVocabularyError):
         vocabulary.create()
Exemplo 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)