public static WordSet RandomModals() { Dictionary <int, int> odds = new Dictionary <int, int> { { 0, 74 }, { 1, 10 }, { 2, 10 }, { 3, 6 }, { 4, 0 }, }; ConvertToCummulative(odds); int dice = random.Next(0, 101); var howMany = odds.Where(x => dice <= x.Value).Select(x => x.Key).First(); WordSet ws = new WordSet(); while (howMany > 0) { ws.Add(new Word(Token.Modals[random.Next(0, Token.Modals.Length)])); howMany--; } return(ws); }
public void DeleteWord() { if (MessageBox.Show("Удлить выбранное слово?", "Удаление элемента", MessageBoxButtons.OKCancel) == DialogResult.OK) { WordSet.Instance().DeleteCurrentItem(); } }
static void GetAllWords(Tile[] tiles, int index, TileWord candidate, List <TileWord> words) { if (!SubWordSet.Contains(candidate.Word)) { return; } tiles[index].IsTaken = true; if (WordSet.Contains(candidate.Word)) { words.Add(candidate); } for (int i = 0; i < 8; i++) { var row = index / 4 + (int)Math.Round(Math.Sin(Math.PI / 4 * (i - 2))); var col = index % 4 + (int)Math.Round(Math.Sin(Math.PI / 4 * i)); if (row >= 0 && row < 4 && col >= 0 && col < 4 && !tiles[row * 4 + col].IsTaken) { GetAllWords(tiles, row * 4 + col, candidate.Add(tiles[row * 4 + col]), words); } } tiles[index].IsTaken = false; }
public void Add(IEnumerable <string> words, string setName, int lang_id, int status_id)//todo textid unsaved { var UserAppId = _workContext.UserAppId; UserProfile user = Repository.GetUserProfile(UserAppId); if (user == null) { throw new Exception("Пользователь не найден"); } WordSet set = Repository.FindBy <WordSet>(s => s.Name == setName && s.User_Id == user.Id).FirstOrDefault(); if (set == null) { set = new WordSet { Name = setName, User = user }; this.Repository.Add(set, true); } var wordsExists = Repository.Words.ToList().AsQueryable(); var userWordsExists = Repository.UserWords.ToList().AsQueryable(); foreach (string word in words) { UserWord newUserWord = new UserWord(word, lang_id, status_id, set.Id, user.Id); newUserWord.Word = wordsExists.FindSameWordOrDefault(newUserWord.Word); if (!IsUserHaveWord(userWordsExists, newUserWord, UserAppId)) { Repository.Add(newUserWord); } } Repository.Save(); }
void OnWizardCreate() { string Allfile = ""; foreach (PuzzleComponent puzzle in Selection.activeGameObject.GetComponentsInChildren <PuzzleComponent>()) { Dictionary <Vector2, string> letterPos = new Dictionary <Vector2, string>(); WordSet wordset = new WordSet(); JsonUtility.FromJsonOverwrite(StringCompressor.DecompressString(puzzle.Content), wordset); foreach (SWord word in wordset.Words) { for (int i = 0; i < word.LocationList.Count; i++) { Vector2 l = word.LocationList[i]; if (letterPos.ContainsKey(l)) { if (letterPos[l] != word.Name[i].ToString()) { Allfile += $"کلمه : {word.Name} در جدول : {puzzle.Clue}+{puzzle.PuzzleData.Row} در مجموعه : {puzzle.transform.parent.GetComponent<CategoryComponent>().CategoryData.Name} \n"; break; } } else { letterPos.Add(l, word.Name[i].ToString()); } } } } System.IO.File.WriteAllText(FileAddress, Allfile); }
private static int GetWordCount(PuzzleComponent p) { WordSet ws = new WordSet(); JsonUtility.FromJsonOverwrite(StringCompressor.DecompressString(p.Content), ws); return(ws.Words.Count); }
public WordSet RandomAdverbs() { Dictionary <int, int> odds = new Dictionary <int, int> { { 0, 88 }, { 1, 7 }, { 2, 5 }, { 3, 0 }, { 4, 0 }, }; ConvertToCummulative(odds); int dice = random.Next(0, 101); var howMany = odds.Where(x => dice <= x.Value).Select(x => x.Key).First(); WordSet ws = new WordSet(); while (howMany > 0) { ws.Add(RandomWord("adv")); howMany--; } return(ws); }
static void Main(string[] args) { var word_set = new WordSet( new[] { "a", "b", "ba", "baa", "bab", "bba", "bbb", "bbc", } ); Console.WriteLine("Prefixes:"); TestPrefix(word_set, "a"); TestPrefix(word_set, "b"); TestPrefix(word_set, "ba"); TestPrefix(word_set, "bb"); TestPrefix(word_set, "bc"); Console.WriteLine("\nSuffixes:"); TestSuffix(word_set, "a"); TestSuffix(word_set, "b"); TestSuffix(word_set, "ba"); TestSuffix(word_set, "bb"); TestSuffix(word_set, "bc"); }
void OnWizardCreate() { foreach (PuzzleComponent puzzle in Selection.activeTransform.GetComponentsInChildren <PuzzleComponent>()) { string c = puzzle.Clue; WordSet ws = new WordSet(); JsonUtility.FromJsonOverwrite(StringCompressor.DecompressString(puzzle.PuzzleData.Content), ws); foreach (SWord word in ws.Words) { List <string> list = new List <string>(); if (_allWords.ContainsKey(word.Name)) { list.AddRange(_allWords[word.Name]); } list.Add(c); _allWords[word.Name] = list; } string export = ""; foreach (string word in _allWords.Keys) { List <string> cats = _allWords[word]; if (cats.Count > 1) { if (CheckSameCetegoryName) { CheckSameCat: for (var i = 0; i < cats.Count - 1; i++) { for (var j = i + 1; j < cats.Count; j++) { if (cats[i].Replace(cats[j], "").Length != cats[i].Length || cats[j].Replace(cats[i], "").Length != cats[j].Length) { cats.RemoveAt(i); goto CheckSameCat; } } } } if (cats.Count < 2) { continue; } export += "\n:\t" + word + "\t"; foreach (string cat in cats) { export += "," + cat; } } } System.IO.File.WriteAllText(FileAddress, export); } }
private void ShowWords() { listView.Items.Clear(); for (int i = 0; i < WordSet.Instance().Count; i++) { listView.Items.Add(WordSet.Instance().GetItem(i).Caption); } }
private void MainForm_Load(object sender, EventArgs e) { LoadSettings(); if (WordSet.Instance().Count > 0) { ShowWordListForm(); } }
public async Task <IActionResult> Post(WordSet set) { await _context.WordSets.AddAsync(set); await _context.SaveChangesAsync(); return(Ok(set)); }
public void IsAnagram_AreStringsBeingAddedToListProp() { List <string> someList = new List <string> { "acbd", "cdab", "adbc" }; WordSet testObj = new WordSet("abcd", someList.ToArray()); Assert.AreEqual(3, testObj.GetTargetList().Count); }
public Word(string name) { this.name = name; frequency = 1; capitalisedWordWeight = 0; followingWords = new WeightedWordDict(); associations = new WordSet(); }
private void NewSet() { //_currentSet = WordSet.Animals; _currentSet = RandomWordSet(); _unusedSets.Remove(_currentSet); Debug.Log(string.Format("The current set is {0}", _currentSet)); _currentWord = ""; currentset_text.text = string.Format("Current Set: {0}", _currentSet); }
public WordSet GetWordSet() { WordSet wordSet = new WordSet(); string decompressString = StringCompressor.DecompressString(Content); string replace = decompressString.Replace("\"Direction\"", "\"WordDirection\""); JsonUtility.FromJsonOverwrite(replace, wordSet); return(wordSet); }
private void SaveSettings() { Properties.Settings.Default.MainForm_Top = this.Top; Properties.Settings.Default.MainForm_Left = this.Left; Properties.Settings.Default.MainForm_Width = this.Width; Properties.Settings.Default.MainForm_Height = this.Height; Properties.Settings.Default.DictFilePath = WordSet.Instance().FilePath; Properties.Settings.Default.Save(); WordSet.Instance().Save(); }
/// <summary> /// Init from file and build tree /// </summary> private void Init() { // Read string[] content = fileProcessor.ReadAllLines(filePath, true); // Parse WordSet wordSet = parser.Parse(content); // Build tree wrapper = new TreeWrapper(wordSet); }
public WordSet GetWord(string word) { word = RemovePunctuationFromWord(word); if (!WordData.ContainsKey(word)) { WordData[word] = new WordSet(word); } return(WordData[word]); }
public List<Word> GetEndingWords(WordSet inputWords) { List<Word> endingWords = new List<Word>(); foreach ( Word word in inputWords ) { if ( ( word.endingWord ) && ( endingWords.Contains(word) == false ) ) { endingWords.Add(word); } } return endingWords; }
public IGuess NextGuess(HangmanGame game) { string pattern = game.GuessedSoFar; ISet <char> guessedLetters = game.AllGuessedLetters; ISet <char> guessed = new HashSet <char>(guessedLetters); ISet <string> wrongWords = game.IncorrectlyGuessedWords; //NOTE: The strategy will make a word guess either when there's only one //word in the wordset, or when there's only one blank left. //When a word guess failed, the incorrectly guessed letter in the word should be //counted. if (wrongWords.Count > 0) { int idx = pattern.IndexOf(HangmanGame.MYSTERY_LETTER); foreach (string wd in wrongWords) { guessed.Add(wd[idx]); } } //Update the wordset when the game status(pattern and guessed) doesn't match. if (!(pattern.Equals(this.wordset.pattern) && guessed.Equals(this.wordset.guessedLetters))) { //Update wordset on a previous guess result, be it successful or not. this.wordset = new WordSet(pattern, guessed, this.wordset); } if (this.wordset.Count == 1) { return(new GuessWord(this.wordset.First())); } int patternBlanks = NumOfBlanks(pattern); if (patternBlanks > 1) { if (game.NumWrongGuessesRemaining == 0) { //Simply return the first word in the word set for the last chance. return(new GuessWord(this.wordset.First())); } else { return(new GuessLetter((this.wordset.Suggest(guessedLetters)))); } } else { //When there's only one blank letter, try to guess the word to save one //score on a successfull guess. char ch = this.wordset.Suggest(guessed); return(new GuessWord(pattern.Replace(HangmanGame.MYSTERY_LETTER, ch))); } }
public void GetAllPartialAnagrams_TestOneToManyStrings_ReturnListOfPartialMatches() { List <string> testStrings = new List <string> { "tab", "table", "dog" }; WordSet testSet = new WordSet("bat", testStrings); List <string> matchedAnagrams = new List <string> { "tab", "table" }; CollectionAssert.AreEqual(matchedAnagrams, testSet.GetAllPartialAnagrams()); }
static void Main(string[] args) { var set = new WordSet(2); set.addWords(File.ReadAllText("..\\..\\..\\NameGen2\\sets\\set1.txt"), ","); while (1 == 1) { Console.WriteLine(NameGen2.MarkovChain.Generate(set, 5, 10)); Console.ReadLine(); } }
private void DeleteWord() { if (activeForm == null) { return; } if (activeForm.Name == "WordListForm") { wordListForm.DeleteWord(); this.lbAppHint.Text = WordSet.Instance().Count.ToString(); } }
public void Save() { WordSet wordSet = GameController.Instance.GetWordSet(); var puzzle = new UserPuzzle { Clue = wordSet.Clue, Content = StringCompressor.CompressString(JsonUtility.ToJson(wordSet)) }; LocalDBController.Instance.UserPuzzles.AddPuzzle(puzzle); }
public static bool TryParse(string value, out WordSet result) { try { result = WordSetTypeConverter.Parse(value); return(true); } catch (Exception) { result = null; return(false); } }
public void SetForSpawn(Puzzle selectedPuzzle) { WordSet wordSet = selectedPuzzle.GetWordSet(); Singleton.Instance.WordSpawner.ClearTable(); Singleton.Instance.WordSpawner.WordSet = wordSet; Singleton.Instance.WordSpawner.Clue = selectedPuzzle.Clue; Singleton.Instance.WordSpawner.PuzzleRow = (selectedPuzzle.Row + 1).ToString(); Singleton.Instance.WordSpawner.PuzzleReward = !selectedPuzzle.Solved; Singleton.Instance.WordSpawner.PuzzleID = selectedPuzzle.ID; Singleton.Instance.WordSpawner.EditorInstatiate = null; }
public ComplexChain RandomEnPiChain() { Word headWord = RandomWord("noun"); WordSet modifiers = new WordSet { RandomWord("adj") }; List <Chain> agents = new List <Chain>(); agents.Add(new Chain(Particles.pi, new[] { new HeadedPhrase(headWord, modifiers) })); ComplexChain c = new ComplexChain(Particles.en, agents.ToArray()); return(c); }
// Use this for initialization public WordSet Save() { WordSet wordSet = new WordSet(); wordSet.Clue = Clue; wordSet.Words = new List <SWord>(); foreach (var word in WordManager.GetComponentsInChildren <Word>()) { wordSet.Words.Add(new SWord(word)); } return(wordSet); }
public void AddWord() { WordEditForm wef = new WordEditForm(); wef.SetEditMode(EditMode.Append); if (wef.ShowDialog() == DialogResult.OK) { DictItem di = new DictItem(); di.Caption = wef.Caption; di.ReadValues(wef.Values); WordSet.Instance().Add(di); listView.Items.Add(new ListViewItem(di.Caption)); } }
//Can be combined with li (predicate) or en (subject). // kasi suli laso ==> kasi suli en kasi laso // kasi suli laso ==> kasi li suli li laso // kasi suli laso ==> kasi li suli. kasi li laso public Chain ExpandedToChain() { List <HeadedPhrase> l = new List <HeadedPhrase>(); foreach (Word modifier in phrase.Modifiers) { WordSet modifiers = new WordSet(); modifiers.Add(modifier); l.Add(new HeadedPhrase(phrase.Head, modifiers)); } Chain c = new Chain(Particles.en, l.ToArray()); return(c); }
private void FillNewRange() { int cnt = 0; while (cnt < choiceVariants) { int next = rand.Next(WordSet.Instance().Count); if (!ItemInRange(WordSet.Instance().GetItem(next).Caption)) { items[cnt] = WordSet.Instance().GetItem(next); cnt++; } } }
public string GenerateSentence(WordSet inputWords, WordSet relatedWords, Word startingWord, Random rand) { //If the starting word is moot, generate another one Word currentWord, lastWord; string ret = ""; int wordCount = 1; int maxWordCount = Math.Min(Sentence.maxWords, wordbank.AverageSentenceLength); maxWordCount = Math.Max(maxWordCount, Sentence.minWords); lastWord = startingWord; ret += Word.ToSentenceCase(lastWord.name); WordSet appearedWords = new WordSet(); while ( wordCount < maxWordCount ) { if ( lastWord.followingWords.Count == 0 ) { break; } WeightedWordDict relatedFollowingWords = GetRelatedWords(lastWord.followingWords, relatedWords); //Tries to choose the current word. If it cant choose a related followed word, choose any followed one if ( wordCount >= Sentence.minWords ) { currentWord = relatedFollowingWords.ChooseRandomEndingWord(rand); if ( currentWord == null ) { currentWord = relatedFollowingWords.ChooseRandomWord(rand); } } else { currentWord = relatedFollowingWords.ChooseRandomWord(rand); } if ( appearedWords.Contains(currentWord) ) { relatedFollowingWords.Remove(currentWord); currentWord = relatedFollowingWords.ChooseRandomWord(rand); } if ( currentWord == null ) { currentWord = lastWord.followingWords.ChooseRandomWord(rand); } if ( currentWord == null ) { DANI.Program.NullError("ChooseRandomWord returned null with non-empty list (last word "+lastWord+")."); break; } appearedWords.Add(currentWord); lastWord = currentWord; ret += " " + currentWord.GetName; wordCount++; if ( ( currentWord.endingWord ) && ( wordCount >= Sentence.minWords ) ) { DANI.Program.DebugMsg("endingWord ended: " + currentWord.GetName); break; } } return ret; }
public WeightedWordDict GetRelatedWords(WeightedWordDict words, WordSet relations) { WeightedWordDict relatedWords = new WeightedWordDict(); foreach ( KeyValuePair<Word, int> pair in words ) { if ( relations.Contains(pair.Key) ) { relatedWords.Add(pair); } } return relatedWords; }
public List<Word> GetStartingWords(WordSet inputWords) { List<Word> startingWords = new List<Word>(); foreach ( Word word in inputWords ) { if ( ( word.startingWord ) && ( startingWords.Contains(word) == false ) ) { startingWords.Add(word); } } return startingWords; }
public WordSet GetRelatedWords(WordSet words) { WordSet relatedWords = new WordSet(); foreach ( Word word in words ) { foreach ( Word associatedWord in word.associations ) { if ( relatedWords.Contains(associatedWord) == false ) { relatedWords.Add(associatedWord); } } } return relatedWords; }
public WordSet TextToWordlist(string text) { WordSet wordlist = new WordSet(); Word currentWord = null; foreach ( string sentence in Sentence.TextToSentences(text) ) { foreach ( string word in Sentence.ToWords(sentence) ) { wordbank.wordlist.TryGetValue(word.ToLower(), out currentWord); if ( ( currentWord != null ) && ( wordlist.Contains(currentWord) == false ) ) { wordlist.Add(currentWord); } } } return wordlist; }