Example #1
0
        /// <summary>
        /// Event fired when the Move Snapshot menu item is clicked from the drop down menu (right click)
        /// </summary>
        private void MoveSnapshotMenuItem_Click(object sender, EventArgs e)
        {
            // Get our snapshot file name
            SnapshotFile sFile = SnapshotView.SelectedItems[0].Tag as SnapshotFile;

            if (sFile == null)
            {
                return;
            }

            // Move the selected snapshot to the opposite folder
            if (ViewSelect.SelectedIndex == 0)
            {
                File.Move(
                    Path.Combine(Paths.SnapshotTempPath, sFile.FileName),
                    Path.Combine(Paths.SnapshotProcPath, sFile.FileName)
                    );
            }
            else
            {
                File.Move(
                    Path.Combine(Paths.SnapshotProcPath, sFile.FileName),
                    Path.Combine(Paths.SnapshotTempPath, sFile.FileName)
                    );
            }

            BuildList();
        }
Example #2
0
        public ISnapshotWriter CreateWriter(string potName)
        {
            PotDirectory potDirectory = PotDirectory.FromPotName(potName);

            if (!potDirectory.IsValid)
            {
                throw new Exception($"There is no pot with name '{potName}'.");
            }

            SnapshotFile    snapshotFile    = potDirectory.CreateSnapshotFile(DateTime.UtcNow);
            JSnapshotWriter jSnapshotWriter = snapshotFile.OpenWriter();

            return(new JsonSnapshotWriter(jSnapshotWriter));
        }
Example #3
0
        public void DeleteByIndex(string potName, int index = 0)
        {
            PotDirectory potDirectory = PotDirectory.FromPotName(potName);

            if (!potDirectory.IsValid)
            {
                throw new Exception($"There is no pot with name '{potName}'.");
            }

            SnapshotFile snapshotFile = potDirectory.GetSnapshotFiles()
                                        .Skip(index)
                                        .FirstOrDefault();

            snapshotFile?.Delete();
        }
Example #4
0
        public void Add(string potName, Snapshot snapshot)
        {
            PotDirectory potDirectory = PotDirectory.FromPotName(potName);

            if (!potDirectory.IsValid)
            {
                throw new Exception($"There is no pot with name '{potName}'.");
            }

            SnapshotFile snapshotFile = potDirectory.CreateSnapshotFile(snapshot.CreationTime);

            snapshotFile.Open();
            snapshotFile.Snapshot = snapshot.ToJSnapshot();
            snapshotFile.Save();
        }
Example #5
0
        /// <summary>
        /// Event fire when the Details item menu is selected from the
        /// context menu
        /// </summary>
        private void Details_MenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                // Get our snapshot file name
                SnapshotFile sFile = SnapshotView.SelectedItems[0].Tag as SnapshotFile;
                if (sFile == null)
                {
                    return;
                }

                // Load up the snapshot, and display the Game Result Window
                Snapshot Snapshot = new Snapshot(File.ReadAllText(sFile.FilePath));
                using (GameResultForm F = new GameResultForm(Snapshot as GameResult, Snapshot.IsProcessed))
                {
                    F.ShowDialog();
                }
            }
            catch { }
        }
Example #6
0
        public bool DeleteByExactDateTime(string potName, DateTime dateTime)
        {
            PotDirectory potDirectory = PotDirectory.FromPotName(potName);

            if (!potDirectory.IsValid)
            {
                throw new Exception($"There is no pot with name '{potName}'.");
            }

            SnapshotFile snapshotFile = potDirectory.GetSnapshotFiles()
                                        .FirstOrDefault(x => x.CreationTime.HasValue && x.CreationTime.Value == dateTime);

            if (snapshotFile == null)
            {
                return(false);
            }

            snapshotFile.Delete();
            return(true);
        }
Example #7
0
        public Snapshot GetByIndex(string potName, int index = 0)
        {
            PotDirectory potDirectory = PotDirectory.FromPotName(potName);

            if (!potDirectory.IsValid)
            {
                throw new Exception($"There is no pot with name '{potName}'.");
            }

            SnapshotFile snapshotFile = potDirectory.GetSnapshotFiles()
                                        .Skip(index)
                                        .FirstOrDefault();

            if (snapshotFile == null)
            {
                return(null);
            }

            snapshotFile.Open();
            return(snapshotFile.Snapshot.ToSnapshot());
        }
Example #8
0
 public Snapshot(SnapshotFile file)
 {
     SnapshotFile = file;
     SnapshotName = SnapshotFile.ItemName + " " + DateTime.UtcNow.ToString();
     Value = File.ReadAllText(file.Location);
 }
Example #9
0
        /// <summary>
        /// Return recognition results.
        /// </summary>
        /// <param name="dc">Context object containing information for a single turn of conversation with a user.</param>
        /// <param name="activity">The incoming activity received from the user. The Text property value is used as the query text for QnA Maker.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <param name="telemetryProperties">Additional properties to be logged to telemetry with the LuisResult event.</param>
        /// <param name="telemetryMetrics">Additional metrics to be logged to telemetry with the LuisResult event.</param>
        /// <returns>A <see cref="RecognizerResult"/> containing the QnA Maker result.</returns>
        public override async Task <RecognizerResult> RecognizeAsync(DialogContext dc, Schema.Activity activity, CancellationToken cancellationToken, Dictionary <string, string> telemetryProperties = null, Dictionary <string, double> telemetryMetrics = null)
        {
            var text            = activity.Text ?? string.Empty;
            var detectAmbiguity = DetectAmbiguousIntents.GetValue(dc.State);

            _modelFolder  = ModelFolder.GetValue(dc.State);
            _snapshotFile = SnapshotFile.GetValue(dc.State);

            InitializeModel();

            var recognizerResult = new RecognizerResult()
            {
                Text    = text,
                Intents = new Dictionary <string, IntentScore>(),
            };

            if (string.IsNullOrWhiteSpace(text))
            {
                // nothing to recognize, return empty recognizerResult
                return(recognizerResult);
            }

            if (ExternalEntityRecognizer != null)
            {
                // Run external recognition
                var externalResults = await ExternalEntityRecognizer.RecognizeAsync(dc, activity, cancellationToken, telemetryProperties, telemetryMetrics).ConfigureAwait(false);

                recognizerResult.Entities = externalResults.Entities;
            }

            // Score with orchestrator
            var results = _resolver.Score(text);

            // Add full recognition result as a 'result' property
            recognizerResult.Properties.Add(ResultProperty, results);

            if (results.Any())
            {
                var topScore = results[0].Score;

                // if top scoring intent is less than threshold, return None
                if (topScore < UnknownIntentFilterScore)
                {
                    recognizerResult.Intents.Add(NoneIntent, new IntentScore()
                    {
                        Score = 1.0
                    });
                }
                else
                {
                    // add top score
                    recognizerResult.Intents.Add(results[0].Label.Name, new IntentScore()
                    {
                        Score = results[0].Score
                    });

                    // Disambiguate if configured
                    if (detectAmbiguity)
                    {
                        var thresholdScore   = DisambiguationScoreThreshold.GetValue(dc.State);
                        var classifyingScore = Math.Round(topScore, 2) - Math.Round(thresholdScore, 2);
                        var ambiguousResults = results.Where(item => item.Score >= classifyingScore).ToList();

                        if (ambiguousResults.Count > 1)
                        {
                            // create a RecognizerResult for each ambiguous result.
                            var recognizerResults = ambiguousResults.Select(result => new RecognizerResult()
                            {
                                Text        = text,
                                AlteredText = result.ClosestText,
                                Entities    = recognizerResult.Entities,
                                Properties  = recognizerResult.Properties,
                                Intents     = new Dictionary <string, IntentScore>()
                                {
                                    { result.Label.Name, new IntentScore()
                                      {
                                          Score = result.Score
                                      } }
                                },
                            });

                            // replace RecognizerResult with ChooseIntent => Ambiguous recognizerResults as candidates.
                            recognizerResult = CreateChooseIntentResult(recognizerResults.ToDictionary(result => Guid.NewGuid().ToString(), result => result));
                        }
                    }
                }
            }
            else
            {
                // Return 'None' if no intent matched.
                recognizerResult.Intents.Add(NoneIntent, new IntentScore()
                {
                    Score = 1.0
                });
            }

            await dc.Context.TraceActivityAsync($"{nameof(OrchestratorAdaptiveRecognizer)}Result", JObject.FromObject(recognizerResult), nameof(OrchestratorAdaptiveRecognizer), "Orchestrator Recognition", cancellationToken).ConfigureAwait(false);

            TrackRecognizerResult(dc, $"{nameof(OrchestratorAdaptiveRecognizer)}Result", FillRecognizerResultTelemetryProperties(recognizerResult, telemetryProperties, dc), telemetryMetrics);

            return(recognizerResult);
        }
 private void treeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
 {
     if (treeView.SelectedItem != null)
     {
         if (treeView.SelectedItem.GetType() == typeof(SnapshotFile))
         {
             currentFile = (SnapshotFile)treeView.SelectedItem;
             comboBox.ItemsSource = null;
             comboBox.ItemsSource = currentFile.Snapshots;
             fileLocation.Text = currentFile.Location;
             if (comboBox.Items.Count > 0)
                 Select((Snapshot)comboBox.Items[0]);
             else
                 DeSelect();
         }
     }
 }