/// <summary> /// Helper method /// </summary> /// <returns>IEnumerable of IWord</returns> private static IEnumerable <IWord> ToEnumerable(IWords words) { for (var i = 0; i < words.Count; i++) { yield return(words[i]); } }
public void ToNewlineStringTest() { TestInfrastructure.DebugLineStart(TestContext); if (TestInfrastructure.IsActive(TestContext)) { using (IDictionary writeLM = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser)) { ICard card = writeLM.Cards.AddNew(); IWords words = card.Question; for (int i = 0; i < TestInfrastructure.Random.Next(10, 50); i++) { IWord word = words.CreateWord("Word " + i.ToString(), WordType.Word, true); words.AddWord(word); } string newLineStringClone = string.Empty; foreach (IWord var in words.Words) { newLineStringClone += var.Word + "\r\n"; } newLineStringClone = newLineStringClone.Substring(0, newLineStringClone.Length - 2); Assert.AreEqual <string>(newLineStringClone, words.ToNewlineString(), "IWords.ToNewlineStringTest does not match with expected output."); } } TestInfrastructure.DebugLineEnd(TestContext); }
/// <summary> /// Get words in input string (JSON) /// </summary> /// Get the component words in an input string, formatted as JSON /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='input'> /// String to process /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <GetWordsJsonOKResponse> GetWordsJsonAsync(this IWords operations, string input, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetWordsJsonWithHttpMessagesAsync(input, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Get adjectives in string /// </summary> /// Retrieves all adjectives in input string /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='input'> /// Input string /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <string> AdjectivesAsync(this IWords operations, string input, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.AdjectivesWithHttpMessagesAsync(input, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
// Connect to server private void ConnectToHangman() { try { // Configure the ABCs of using the MessageBoard service DuplexChannelFactory <IWords> channel = new DuplexChannelFactory <IWords>(this, "HangmanEndpoint"); // Activate a MessageBoard object wordInstance = channel.CreateChannel(); if (wordInstance.NewPlayer(tbName.Text)) { // Hide login, so they cant login again LoginPanel.Visibility = Visibility.Hidden; buttonPanel.IsEnabled = true; // Set player board SetPlayers(); } else { // New player name rejected by the service so nullify service proxies wordInstance = null; MessageBox.Show("ERROR: Username in use. Please try again."); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Render(IWords Iworld, IForms IfieldForm) //мир и формы должны через интерфейсную ссылку передаваться { this.Iworld = Iworld; //или перегружать класс будем(хуже) if (IfieldForm is FieldForm1) { fieldForm = IfieldForm as FieldForm1; } //РАЗВИЛКА!!!!!! if (Iworld is World_1) { world = Iworld as World_1; verwolfHeight = world.verwolfHeight; verwolfWight = world.verwolfWight; subjectPanelGame = world.subjectsPanel; hero = world.hero; fieldForm.renderer = this; //ПОДПИСКИ НА СОБЫТИЯ ФОРМЫ---> ****вервольфа нужно обобщать через интерфейс или абстрактный класс //this.fieldForm.eTruck += new FieldForm.Truck(DrawTrucks); fieldForm.eFieldMouseClick += new FieldMouseClick(DrawCaptureObjects); //ПОДПИСКА ЧЕРЕЗ АНОНИМНЫЙ МЕТОД--->снимаем управление с Hero fieldForm.eFieldMouseUp += delegate(object sender, MouseEventArgs e){ if (hero.CurrentState == stateHero.Control && Math.Abs(hero.Location.X - e.Location.X) < hero.rangeHero && Math.Abs(hero.Location.Y - e.Location.Y) < hero.rangeHero) { if (e.Button == MouseButtons.Right) { hero.CurrentState = stateHero.Stay; } } }; //ПОДПИСКА ЧЕРЕЗ ЛЯМБДА fieldForm.eFieldMouseMove += (sender, e) => { Point verwolfBeginLocation = world.verfolfBeginLocation; int rateX = verwolfBeginLocation.X + world.verwolfWight; int rateY = verwolfBeginLocation.Y + world.verwolfHeight; if (e.Location.X > verwolfBeginLocation.X && e.Location.X < rateX && e.Location.Y > verwolfBeginLocation.Y && e.Location.Y < rateY && world.verwolf.CurrentState == WolfState.Stay) { DrawTrucks(true); } else { DrawTrucks(false); } }; } InitializeImages(); hero = world.hero; }
private string GetAnswer(IWords wordsLogic) { var words = wordsLogic.GetWords(); var rnd = new Random(); return(words[rnd.Next(words.Count)]); }
public List <string> GetWordCombinations() { IWords words = GetWords(); WordsCombinator wordCombinator = new WordsCombinator(words, 6); return(wordCombinator.GetAllCombinatedWordsAsList()); }
public void AddWords(IWords words) { foreach (Word word in words.GetList()) { if (IsValidWord(word.Value)) { _hashSet.Add(word.Value); } } }
public TensorflowSentiment(Configuration config, IWords wordVectors) { _wordVectors = wordVectors ?? throw new ArgumentNullException(nameof(wordVectors)); var cfg = config.Sentiment ?? throw new ArgumentNullException(nameof(config.Sentiment)); _sentimentModelPath = cfg.SentimentModelPath ?? throw new ArgumentNullException(nameof(config.Sentiment.SentimentModelPath)); _sentimentModelInput = cfg.SentimentModelInputLayer ?? throw new ArgumentNullException(nameof(config.Sentiment.SentimentModelInputLayer)); _sentimentModelOutput = cfg.SentimentModelOutputLayer ?? throw new ArgumentNullException(nameof(config.Sentiment.SentimentModelOutputLayer)); _graph = Task.Run(async() => await LoadGraph()); }
public Hive(IWords world) //вторым параметром могли передать делегат sendMessage { World = world as World_1;; Honey = InitialHoney; InitializeLocation(); Random random = new Random(); for (int i = 0; i < InitialBees; i++) { AddBee(random); } }
//РАЗДЕЛ ВИЗУАЛИЗАЦИИ МИРОВ void StartWorld(IWords Iworld) { if (Iworld is World_1) { fieldForm = IForm1 as FieldForm1; fieldForm.Show(); renderer.Render(Iworld, IForm1); //запуск мира №1 //else if(Iworld is World2) //...................... //......................} } }
public static void CopyWords(IWords source, IWords target) { if (!typeof(IWords).IsAssignableFrom(target.GetType())) { throw new ArgumentException("Target must implement IWords!"); } foreach (IWord word in source.Words) { IWord newWord = target.CreateWord(word.Word, word.Type, word.Default); target.AddWord(newWord); } }
public void GetCurrentWorld(IWords iword) { //РАЗДЕЛ НАСТРОЕК ГЕРОЯ ДЛЯ КАЖДОГО МИРА if (iword is World_1) { this.iword = iword; World_1 world = iword as World_1; Location = world.heroBeginLocation; verwolf = world.verwolf; CurrentState = stateHero.Stay; rangeHero = 50; } }
public Marger(int fileCount, WordsCountQueue queue, IWords totalResult, ManualResetEventSlim stopEvent, Action <Exception> applExceptionHandler) { _fileCount = fileCount; _queue = queue; _totalResult = totalResult; _stopEvent = stopEvent; _applExceptionHandler = applExceptionHandler; var innerThread = new Thread(Run) { Name = "Marger" }; innerThread.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="DbCard"/> class. /// </summary> /// <param name="id">The id.</param> /// <param name="checkId">if set to <c>true</c> [check id].</param> /// <param name="parentClass">The parent class.</param> /// <remarks>Documented by Dev03, 2009-01-13</remarks> public DbCard(int id, bool checkId, ParentClass parentClass) { parent = parentClass; if (checkId) connector.CheckCardId(id); this.id = id; question = new DbWords(id, Side.Question, WordType.Word, Parent.GetChildParentClass(this)); questionExample = new DbWords(id, Side.Question, WordType.Sentence, Parent.GetChildParentClass(this)); questionDistractors = new DbWords(id, Side.Question, WordType.Distractor, Parent.GetChildParentClass(this)); answer = new DbWords(id, Side.Answer, WordType.Word, Parent.GetChildParentClass(this)); answerExample = new DbWords(id, Side.Answer, WordType.Sentence, Parent.GetChildParentClass(this)); answerDistractors = new DbWords(id, Side.Answer, WordType.Distractor, Parent.GetChildParentClass(this)); }
public void RunGame(IWords wordsLogic) { var gameState = new GameState(wordsLogic); InitialiseNewGame(gameState, wordsLogic); bool run = true; RenderState(gameState); while (run) { var keyInfo = Console.ReadKey(); run = keyInfo.Key != ConsoleKey.Escape; if (run) { if ((gameState.CurrentPhase == GamePhase.Lost || gameState.CurrentPhase == GamePhase.Won)) { if (keyInfo.KeyChar == 'y') { InitialiseNewGame(gameState, wordsLogic); } else { run = false; } } else { if (gameState.CurrentPhase == GamePhase.Playing) { AddGuess(gameState, keyInfo.KeyChar); } } if (run) { RenderState(gameState); } } } }
////ИСХОДНАЯ ТОЧКА, ОТКУДА ЗАПУСКАЕТСЯ МИР И ВИЗУАЛИЗАТОР private void ResetSimulator() { framesRun = 0; renderer = new Renderer(); GameOver pipec = new GameOver(YouLost); hero = new Hero(); //герой общий для всех миров hero.eExchangeWorld += new ExchangeWorld(CurrentExit); timer1.Enabled = true; timer2.Enabled = true; Iworld1 = new World_1(fillPanel, pipec, subjectsPanel, hero); World_1 w1 = Iworld1 as World_1; exchangePortal.Add(Iworld1.Exit, w1.hive); //т.к. у нас пчелы в улье создаются, а сначала мы мир открываем, то вот такие пляски currentWorld = Iworld1; hero.GetCurrentWorld(Iworld1); //герой узнает о мире Iworld1.renderer = renderer; IForm1 = new FieldForm1(); StartWorld(Iworld1); }
public void ClearWordsTest() { TestInfrastructure.DebugLineStart(TestContext); if (TestInfrastructure.IsActive(TestContext)) { using (IDictionary writeLM = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser)) { ICard card = writeLM.Cards.AddNew(); IWords words = card.Question; for (int i = 0; i < TestInfrastructure.Random.Next(10, 50); i++) { IWord word = words.CreateWord("Word " + i.ToString(), WordType.Word, true); words.AddWord(word); } words.ClearWords(); Assert.IsTrue(words.Words.Count == 0, "IWords.ClearWords does not delete all words."); } } TestInfrastructure.DebugLineEnd(TestContext); }
public void SetStrategy(IWords strategy) { this._strategy = strategy; }
/// <summary> /// Initializes this instance. /// </summary> /// <remarks>Documented by Dev02, 2008-09-23</remarks> private void Initialize() { question = new PreviewWords(null); questionExample = new PreviewWords(null); questionDistractors = new PreviewWords(null); answer = new PreviewWords(null); answerExample = new PreviewWords(null); answerDistractors = new PreviewWords(null); }
public HomeController(IWords words) { this._words = words; }
public Words(IWords strategy) { this._strategy = strategy; }
public static void CopyWords(IWords source, IWords target) { if (!typeof(IWords).IsAssignableFrom(target.GetType())) throw new ArgumentException("Target must implement IWords!"); foreach (IWord word in source.Words) { IWord newWord = target.CreateWord(word.Word, word.Type, word.Default); target.AddWord(newWord); } }
public WordsCombinator(IWords words, int combinedWordSize) { _words = words; _combinedWordSize = combinedWordSize; }
/// <summary> /// Constructor /// </summary> public QuiddlerService() { try { // Create a StreamWriter object for logging events logger = new Logger("Quiddler_Service.log", LoggingMode.Debug); // Load configuration settings settings = new QuiddlerConfig("Resources/gameConfig.xml"); // Initialize members users = new Dictionary<int, UserDC>(); clients = new Dictionary<int, ICallback>(); deck = new Deck(); words = new Words(WordSource.TextFile, "Resources/Data/Words.txt"); // Log success logger.logInfo("Service created"); } catch (FileLoadException ex) { logger.logError(ex.Message); throw ex; } catch (FileNotFoundException ex) { logger.logError(ex.Message); throw ex; } catch (OleDbException ex) { logger.logError(ex.Message); throw ex; } catch (Exception ex) { logger.logError(ex.Message); throw ex; } }
public GameState(IWords wordsLogic) { WordsLogic = wordsLogic; }
/// <summary> /// Get words in input string (JSON) /// </summary> /// Get the component words in an input string, formatted as JSON /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='input'> /// String to process /// </param> public static GetWordsJsonOKResponse GetWordsJson(this IWords operations, string input) { return(Task.Factory.StartNew(s => ((IWords)s).GetWordsJsonAsync(input), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
public WordsOperator(IWords words) { this.words = words; this.listOfWordsFromASpecificPattern = new List <string>(); this.collectedWordsFromCrossword = new List <string>(); }
/// <summary> /// Initializes this instance. /// </summary> /// <remarks>Documented by Dev03, 2007-08-06</remarks> private void Initialize() { m_questionMedia.Clear(); m_answerMedia.Clear(); foreach (XmlNode xnMedia in m_card.SelectNodes("questionaudio")) { XmlNode xaId; bool isDefault = false; if ((xaId = xnMedia.Attributes.GetNamedItem("id")) != null) if (xaId.Value.Equals("std")) isDefault = true; m_questionMedia.Add(new XmlAudio(Dictionary, xnMedia.InnerText, isDefault, false, Parent.GetChildParentClass(this))); } foreach (XmlNode xnMedia in m_card.SelectNodes("questionexampleaudio")) { m_questionMedia.Add(new XmlAudio(Dictionary, xnMedia.InnerText, false, true, Parent.GetChildParentClass(this))); } foreach (XmlNode xnMedia in m_card.SelectNodes("answeraudio")) { XmlNode xaId; bool isDefault = false; if ((xaId = xnMedia.Attributes.GetNamedItem("id")) != null) if (xaId.Value.Equals("std")) isDefault = true; m_answerMedia.Add(new XmlAudio(Dictionary, xnMedia.InnerText, isDefault, false, Parent.GetChildParentClass(this))); } foreach (XmlNode xnMedia in m_card.SelectNodes("answerexampleaudio")) { m_answerMedia.Add(new XmlAudio(Dictionary, xnMedia.InnerText, false, true, Parent.GetChildParentClass(this))); } foreach (XmlNode xnMedia in m_card.SelectNodes("questionvideo")) { m_questionMedia.Add(new XmlVideo(Dictionary, xnMedia.InnerText, Parent.GetChildParentClass(this))); } foreach (XmlNode xnMedia in m_card.SelectNodes("answervideo")) { m_answerMedia.Add(new XmlVideo(Dictionary, xnMedia.InnerText, Parent.GetChildParentClass(this))); } foreach (XmlNode xnMedia in m_card.SelectNodes("questionimage")) { XmlNode xaWidht, xaHeight; int width = 0, height = 0; if ((xaWidht = xnMedia.Attributes.GetNamedItem("width")) != null) { Int32.TryParse(xaWidht.Value, out width); } if ((xaHeight = xnMedia.Attributes.GetNamedItem("height")) != null) { Int32.TryParse(xaHeight.Value, out height); } m_questionMedia.Add(new XmlImage(Dictionary, xnMedia.InnerText, width, height, true, Parent.GetChildParentClass(this))); } foreach (XmlNode xnMedia in m_card.SelectNodes("answerimage")) { XmlNode xaWidht, xaHeight; int width = 0, height = 0; if ((xaWidht = xnMedia.Attributes.GetNamedItem("width")) != null) { Int32.TryParse(xaWidht.Value, out width); } if ((xaHeight = xnMedia.Attributes.GetNamedItem("height")) != null) { Int32.TryParse(xaHeight.Value, out height); } m_answerMedia.Add(new XmlImage(Dictionary, xnMedia.InnerText, width, height, true, Parent.GetChildParentClass(this))); } foreach (XmlNode xnMedia in m_card.SelectNodes("unusedmedia")) { //unused (not active) media is added to answer media string mediaPath = xnMedia.InnerText; EMedia mediaType; XmlAttribute xaType = xnMedia.Attributes["type"]; if (xaType != null) { mediaType = (EMedia)Enum.Parse(typeof(EMedia), xaType.Value, true); } else { mediaType = DAL.Helper.GetMediaType(mediaPath); } switch (mediaType) { case EMedia.Audio: m_answerMedia.Add(new XmlAudio(Dictionary, mediaPath, false, false, false, Parent.GetChildParentClass(this))); break; case EMedia.Video: m_answerMedia.Add(new XmlVideo(Dictionary, mediaPath, false, Parent.GetChildParentClass(this))); break; case EMedia.Image: m_answerMedia.Add(new XmlImage(Dictionary, mediaPath, false, Parent.GetChildParentClass(this))); break; case EMedia.Unknown: default: break; } } m_question = new XmlQuestion(this, Parent.GetChildParentClass(this)); m_questionExample = new XmlQuestionExample(this, Parent.GetChildParentClass(this)); m_answer = new XmlAnswer(this, Parent.GetChildParentClass(this)); m_answerExample = new XmlAnswerExample(this, Parent.GetChildParentClass(this)); m_QuestionDistractors = new XmlQuestionDistractors(m_oDictionary, this, Parent.GetChildParentClass(this)); m_AnswerDistractors = new XmlAnswerDistractors(m_oDictionary, this, Parent.GetChildParentClass(this)); if (m_card["timestamp"] != null) { m_timestamp = XmlConvert.ToDateTime(m_card["timestamp"].InnerText, XmlDateTimeSerializationMode.RoundtripKind); } else { Timestamp = DateTime.Now; } m_random = m_oDictionary.GetRandomNumber(); }
public Shiritori(WordsService words, Random random, IWords wordVectors) { _words = words; _random = random; _wordVectors = wordVectors; }
public TensorflowSentiment([NotNull] Configuration config, IWords wordVectors) { _wordVectors = wordVectors; _config = config.Sentiment; _graph = Task.Run(async() => await LoadGraph()); }
public static List <int> FillDummyDic(IDictionary target) { Debug.WriteLine(TestInfrastructure.beginLine + " Now filling Demodictionary " + TestInfrastructure.beginLine); List <int> chapters = new List <int>(); for (int k = 0; k < 10; k++) { IChapter chapter = target.Chapters.AddNew(); chapter.Title = "Chapter " + Convert.ToString(k + 1); chapters.Add(chapter.Id); target.DefaultSettings.SelectedLearnChapters.Add(chapter.Id); target.UserSettings.SelectedLearnChapters.Add(chapter.Id); } for (int k = 0; k < TestInfrastructure.Loopcount; k++) { ICard card = target.Cards.AddNew(); card.Chapter = chapters[TestInfrastructure.Random.Next(0, chapters.Count)]; int box = TestInfrastructure.Random.Next(0, 10); card.Box = (box == 11) ? -1 : box; List <IWord> questionWords = new List <IWord>(); List <IWord> questionDistractors = new List <IWord>(); List <IWord> questionExamples = new List <IWord>(); List <IWord> answerWords = new List <IWord>(); List <IWord> answerDistractors = new List <IWord>(); List <IWord> answerExamples = new List <IWord>(); IWords words = card.Question; for (int i = 0; i < TestInfrastructure.Random.Next(1, 5); i++) { IWord word = words.CreateWord("Question_" + Convert.ToString(k + 1) + "_" + Convert.ToString(i + 1), WordType.Word, (i == 0)); questionWords.Add(word); } for (int i = 0; i < TestInfrastructure.Random.Next(1, 5); i++) { IWord word = words.CreateWord("QuestionDistractor_" + Convert.ToString(k + 1) + "_" + Convert.ToString(i + 1), WordType.Distractor, false); questionDistractors.Add(word); } for (int i = 0; i < TestInfrastructure.Random.Next(1, 5); i++) { IWord word = words.CreateWord("QuestionExample_" + Convert.ToString(k + 1) + "_" + Convert.ToString(i + 1), WordType.Sentence, false); questionExamples.Add(word); } words = card.Answer; for (int i = 0; i < TestInfrastructure.Random.Next(1, 5); i++) { IWord word = words.CreateWord("Answer_" + Convert.ToString(k + 1) + "_" + Convert.ToString(i + 1), WordType.Word, (i == 0)); answerWords.Add(word); } for (int i = 0; i < TestInfrastructure.Random.Next(1, 5); i++) { IWord word = words.CreateWord("AnswerDistractor_" + Convert.ToString(k + 1) + "_" + Convert.ToString(i + 1), WordType.Distractor, false); answerDistractors.Add(word); } for (int i = 0; i < TestInfrastructure.Random.Next(1, 5); i++) { IWord word = words.CreateWord("AnswerExample_" + Convert.ToString(k + 1) + "_" + Convert.ToString(i + 1), WordType.Sentence, false); answerExamples.Add(word); } card.Question.AddWords(questionWords); card.QuestionDistractors.AddWords(questionDistractors); card.QuestionExample.AddWords(questionExamples); card.Answer.AddWords(answerWords); card.AnswerDistractors.AddWords(answerDistractors); card.AnswerExample.AddWords(answerExamples); } Debug.WriteLine(TestInfrastructure.endLine + " Demodictionary filled " + TestInfrastructure.endLine); return(chapters); }
public Words(IWords wordVectors, IWordTraining training) { _wordVectors = wordVectors; _training = training; }
public ChartVM(IUnitOfWork uw) { //Contract.Requires(model != null); _uow = uw; word = new WordsService(_uow); }