public static bool Run( App app, string dir, Func <bool> IsTerminated) { const int CAPACITY = 1048576, DIMS = 3; string outputFileName = Path.GetTempFileName(); var expected = new System.Ai.Model(CAPACITY, DIMS); var a = expected.Push("a"); a.SetScore(+0.5f); a.SetVector( new Complex[] { new Complex(0, 1), new Complex(2, 3), new Complex(4, 5) }); var b = expected.Push("z"); b.SetScore(-0.5f); b.SetVector( new Complex[] { new Complex(-6, -7), new Complex(-8, -9), new Complex(-10, -11) }); var sort = expected.Sort(); Model.Dump(sort, expected.Dims, Path.ChangeExtension(outputFileName, ".md")); Model.Write(Path.ChangeExtension(outputFileName, ".model"), sort, expected.Dims); var loaded = Model.Read(Path.ChangeExtension(outputFileName, ".model")).ToArray(); return(false); }
public static bool Count( App app, Args args, Func <bool> IsTerminated) { var Model = new System.Ai.Model(args.Capacity, 0); var Files = Tools.GetFiles( args.SearchPath, args.SearchPattern, args.SearchOption); foreach (var file in Files) { Console.WriteLine($"Reading {Tools.GetShortPath(file)}..."); string buff = File.ReadAllText(file); foreach (var t in PlainText.ForEach(buff)) { if (t.Type == PlainTextTag.TEXT) { var k = args.Orthography.GetKey(buff.Substring( t.StartIndex, t.Length)); if (k != null && k.Length > 0) { //var y = Model.Push(k); //y++; var ids = args.Orthography.Decompose(k); if (ids != null) { foreach (var id in ids) { var sub = Model.Push(id); sub++; } } } } } } Tensor[] sort; sort = Model.Sort(); App.StartWin32UI(null, Curves.DrawCounts, () => sort, $"{args.SearchPath} - Distribution", Color.White, Properties.Resources.Oxygen, new Size(623, 400)); Model.Dump(sort, Model.Dims, Path.ChangeExtension(args.OutputFileName, ".md")); return(false); }