LogosLink Programmer's Guide · LogosLink Programmer's Interface version 2.0.1

Carry Out Balance Analytics on a Context

The following example shows how to run balance analytics on a context.

To execute this code, you will need ContextEngine package.

    using Incipit.LogosLink.ContextEngine;
    using Incipit.LogosLink.ContextEngine.Analytics.Balance;

    //load a context from a file.
    var cxp = new ContextPersister("MyUserName");
    var cx = cxp.LoadContext("C:\\Temp\\Test Models\\Test Context.llx").Context;

    //prepare and run a balance analyser.
    var ana = new BalanceAnalyser(cx);
    ana.Progress += (_, e) => Console.WriteLine($"Progress: {e.Progress:N0} %");
    ana.Run();

    //print out overall balance.
    Console.WriteLine($"Overall balance: {ana.BalanceOverallResults.BalanceOverall:P2}");

    //get results and save them to disk.
    string strResults = ana.ComposeBalanceByThemeResultsTable();
    File.WriteAllText("C:\\Temp\\Test Models\\ContextBalanceByTheme.txt", strResults);

In lines 5-6, we load a context from a file.

In lines 9-11, we create a balance analyser for the context just loaded, we add an event handler to print out progress messages, and finally we run the analyser.

In line 14, we print out the overall balance of the context.

In line 17, we get the analytics results by theme into a text table. Finally, in line 18, we save the text table results into a file on disk.


Contents distributed under a Creative Commons Attribution 4.0 International License · About · Terms of Use · Contact Us · last updated on 21/04/2025 16:01