Corpus
Google Gemini corpus
# clean up
corpuses := Corpus->List();
each(corpus in corpuses) {
documents := Document->List(corpus);
each(document in documents) {
chunks := Chunk->List(document);
each(chunk in chunks) {
chunk->Delete()->PrintLine();
};
document->Delete()->PrintLine();
};
corpus->Delete()->PrintLine();
};
# corups
corpus := Corpus->Create("Corpus 1");
metadata := Map->New()<String, String>;
metadata->Insert("about", "fruit, vegetable, vehicle, human, and animal");
document := Document->Create("Document 1", metadata, corpus);
metadata := Map->New()<String, String>;
metadata->Insert("category", "fruit");
Chunk->Create("Nature's candy! Seeds' sweet ride to spread, bursting with colors, sugars, and vitamins. Fuel for us, future for plants. Deliciously vital!", metadata, document)->ToString()->PrintLine();
metadata := Map->New()<String, String>;
metadata->Insert("category", "vegetable");
Chunk->Create("Not just leaves! Veggies sprout from roots, stems, flowers, and even bulbs. Packed with vitamins, minerals, and fiber galore, they fuel our bodies and keep us wanting more.", metadata, document)->ToString()->PrintLine();
metadata := Map->New()<String, String>;
metadata->Insert("category", "vehicle");
Chunk->Create("Metal chariots or whirring steeds, gliding on land, skimming seas, piercing clouds. Carrying souls near and far, vehicles weave paths for dreams and scars.", metadata, document)->ToString()->PrintLine();
metadata := Map->New()<String, String>;
metadata->Insert("category", "human");
Chunk->Create("Walking contradictions, minds aflame, built for laughter, prone to shame. Woven from stardust, shaped by clay, seeking answers, paving the way.", metadata, document)->ToString()->PrintLine();
metadata := Map->New()<String, String>;
metadata->Insert("category", "animal");
Chunk->Create("Sentient dance beneath the sun, from buzzing flies to whales that run. Flesh and feather, scale and claw, weaving instincts in nature's law. ", metadata, document)->ToString()->PrintLine();
metadata := Map->New()<String, String>;
metadata->Insert("category", "other");
Chunk->Create("Except for fruit, vegetable, vehicle, human, and animal", metadata, document)->ToString()->PrintLine();
# search
results := document->Query(query);
each(result in results) {
relevance := result->GetFirst()->As(FloatRef);
metadata := result->GetThird()->As(Map<String, String>);
relevance->PrintLine();
metadata->ToString()->PrintLine();
"---"->PrintLine();
}
Operations
Create
Create a new corpus
function : Create(name:String) ~ Corpus
Parameters
Name | Type | Description |
---|---|---|
name | String | corpus name |
Return
Type | Description |
---|---|
Corpus | new corpus |
Delete
Delete existing corpus
method : public : Delete() ~ Bool
Return
Type | Description |
---|---|
Bool | true if successful, false otherwise |
Get
Get existing corpus
function : Get(name:String) ~ Corpus
Parameters
Name | Type | Description |
---|---|---|
name | String | corpus name |
Return
Type | Description |
---|---|
Corpus | existing corpus |
GetCreateTime
Get creation time
method : public : GetCreateTime() ~ System.Time.Date
Return
Type | Description |
---|---|
System.Time.Date | creation time |
GetName
Get the display name
method : public : GetName() ~ String
Return
Type | Description |
---|---|
String | display name |
GetUpdateTime
Get update time
method : public : GetUpdateTime() ~ System.Time.Date
Return
Type | Description |
---|---|
System.Time.Date | update time |
Query
Query the corpus
method : public : Query(query:String) ~ Vector<Collection.Tuple.Triplet<FloatRef,String,Map<String,String>>>
Parameters
Name | Type | Description |
---|---|---|
query | String | string query |
Return
Type | Description |
---|---|
Vector<CollectionTupleTriplet<FloatRef,String,Map<String,String>>> | query results as triple, 1) relevance, 2) string content, 3) content metadata |
ToString
String representation of the object
method : public : ToString() ~ String
Return
Type | Description |
---|---|
String | string representation |