Beispiel #1
0
 def test_get_id(self):
     vocabulary = Vocabulary()
     some_id = None
     self.assertEqual(vocabulary.get_id(), str(some_id))
# 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)
model.create()

# 5- Wait to finish
model.wait_for_completion()

# 6- Export Field results
result = Result(model.get_id())
Beispiel #3
0
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)
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")