public void GeneratePasswordList() { var results = new List <string>(); var wordBank = new WordBank(); AddWordElements(wordBank); var permutationCount = new Dictionary <int, long>(); for (var totalElements = _minimum; totalElements <= _maximum; totalElements++) { permutationCount.Add(totalElements, wordBank.CountPermutations(totalElements)); } Console.WriteLine($"A total of {permutationCount.Values.Sum()} permutations will be generated."); using (var logger = new FileLogger()) { for (var totalElements = _minimum; totalElements <= _maximum; totalElements++) { Console.WriteLine($"Generating {permutationCount[totalElements]} {totalElements} word permutations..."); wordBank.MaxElements = totalElements; foreach (var phrase in wordBank) { logger.Log(phrase); } } } }
/* public double[] DecidedSentences(IList<string[]> sentences) * { * double[] favorAndDesfavor = new double[2]; * * double favorability = 0.0; * double desfavorability = 0.0; * * double countPositive = 0.0; * double countNegative = 0.0; * * foreach (string[] words in sentences) * { * int qualification = DecidedSentence(words); * * if (qualification > 5 ) * { * countPositive++; * } * else if(qualification < -5) * { * countNegative++; * } * } * * favorability = (countPositive / sentences.Count); * desfavorability = (countNegative / sentences.Count); * favorAndDesfavor[0] = favorability; * favorAndDesfavor[1] = desfavorability; * * return favorAndDesfavor; * }*/ public override int Decided(int[] input) { int max = 5 * input.Length; int min = -5 * input.Length; Dictionary <string, int> bank = WordBank.GetWords(); List <string> words = bank.Keys.ToList(); int total = 0; for (int i = 0; i < input.Length; i++) { bank.TryGetValue(words[i], out int a); total += input[i] * a; } int ret = -2; int negativo = (max + 2 * min) / 3; int positivo = (2 * max + min) / 3; if (total < negativo) { ret = -1; } else if (total >= negativo && total <= positivo) { ret = 0; } else { ret = 1; } return(ret); }
public void AddWordToQueue(WordBank word, WikiSession aWikiSession) { this.AddWordsToQueue(new List <WordBank>() { word }, aWikiSession); }
public void GeneratePasswordList() { var results = new List <string>(); var wordBank = new WordBank(); AddWordElements(wordBank); var permutationCount = new Dictionary <int, int>(); for (var totalElements = _minimum; totalElements <= _maximum; totalElements++) { permutationCount.Add(totalElements, wordBank.CountPermutations(totalElements)); } Console.WriteLine($"A total of {permutationCount.Values.Sum()} permutations will be generated."); var outputFile = $"output-{DateTime.Now.ToFileTime()}.txt"; using (System.IO.StreamWriter file = new System.IO.StreamWriter(outputFile)) { for (var totalElements = _minimum; totalElements <= _maximum; totalElements++) { Console.WriteLine($"Generating {permutationCount[totalElements]} {totalElements} word permutations..."); //results.AddRange(phraseHelper.PermutatePhrase(totalElements, new List<int>())); wordBank.MaxElements = totalElements; foreach (var phrase in wordBank) { file.WriteLine(phrase); } } Console.WriteLine($"Results written to {outputFile}"); } Console.WriteLine("All done."); }
static void Main(string[] args) { string[] text = System.IO.File.ReadAllText("D:\\Eclips projects\\wiki-surf-dev-project\\WikiSurfCore\\WikiProcess\\words.txt").Replace("\r", "").Split('\n'); using (var db = new WikiSurfCore.WikiSurfContext()) { var wiki = new Wiki("TheNameOfMyBot/1.0", "en.wikipedia.org", "https://en.wikipedia.org/w/api.php"); foreach (var row in text) { var pages = wiki.Query.search(row.Trim()) .Select(x => x.title) .ToList() .Where(x => x.Trim().ToLower() == row.Trim().ToLower()) .ToList(); if (pages.Count > 0) { if (db.WordBanks.FirstOrDefault(x => x.Word == row.Trim()) == null) { db.WordBanks.Add(WordBank.AddWord(row.Trim())); db.SaveChanges(); } } } } }
public void FileCanBeDeleted() { WordBank wordBank = new WordBank(); wordBank.CreateFile(); bool result = wordBank.DeleteFile(); Assert.True(result); }
void Update() { // new requests foreach (var tag in VideoManager.Inst.UsedTags) { if (!WordsForTag.ContainsKey(tag)) { WordsForTag[tag] = new WordBank(); requests.Add(new WordRequest(BaseUrl, tag, tag)); } } // check request for (var i = 0; i < requests.Count; i++) { var request = requests[i]; if (request.Request.isDone) { requests.RemoveAt(i); i--; var words = JsonUtility.FromJson <Words>("{\"words\":" + request.Request.text + "}").words; var bank = WordsForTag[request.Tag]; bank.NextQueryWord = words.Length > 0 ? words.Random().word : null; foreach (var word in words) { bank.AvailableWords.Enqueue(word); } Debug.Log("WORDS FOR " + request.Tag + " (" + request.Word + "): " + string.Join(", ", bank.AvailableWords.ToList().Map(x => x.word))); Debug.Log("NEXT FOR " + request.Tag + " (" + request.Word + "): " + bank.NextQueryWord); } } // new words correctWordTime -= Time.deltaTime; if (correctWordTime <= 0) { var playingPanel = VideoManager.Inst.Panels.RandomWhere(p => p.CurrentState == VideoState.Playing); if (playingPanel != null) { var correctWord = GrabWordForTag(playingPanel.Link.tag); SpawnWord(playingPanel.Link.tag, correctWord); correctWordTime = CorrectWordInterval * Mathf.Lerp(0.8f, 1.25f, Random.value) * Mathf.Pow(0.92f, VideoManager.Inst.Panels.Count); } } wrongWordTime -= Time.deltaTime; if (wrongWordTime <= 0) { var playingPanel = VideoManager.Inst.Panels.RandomWhere(p => p.CurrentState == VideoState.Playing); if (playingPanel != null) { var wrongWord = GrabWordForTag(playingPanel.WrongTag); SpawnWord(playingPanel.WrongTag, wrongWord); wrongWordTime = WrongWordInterval * Mathf.Lerp(0.8f, 1.25f, Random.value) * Mathf.Pow(0.92f, VideoManager.Inst.Panels.Count); } } }
public int DecidedSentence(string[] sentence) { int qualification = 0; foreach (string word in sentence) { qualification += WordBank.GetValue(word); } return(qualification); }
public void ShouldDeleteWordFromFile() { string[] word = { "test1", "test2" }; WordBank wordBank = new WordBank(); wordBank.CreateFile(); wordBank.WriteToFile(word); wordBank.DeleteWordFromFile("test1"); string[] result = wordBank.GetAllWords(); Assert.Single(result); Assert.Equal(word[1], result[0]); }
public void ShouldReturnAllWordsFromFile() { string[] word = { "test1", "test2" }; WordBank wordBank = new WordBank(); wordBank.CreateFile(); wordBank.WriteToFile(word); string[] result = wordBank.GetAllWords(); Assert.Equal(word[0], result[0]); Assert.Equal(word[1], result[1]); }
public void ShouldReturnAWordInFile() { string[] word = { "test" }; WordBank wordBank = new WordBank(); wordBank.WordBankCounter = 0; wordBank.CreateFile(); wordBank.WriteToFile(word); string result = wordBank.GenerateWord(); Assert.Equal(1, wordBank.WordBankCounter); Assert.Equal(word[0], result); wordBank.DeleteFile(); }
private void AddWordElements(WordBank wordBank) { Console.WriteLine("Adding base words..."); var symbolMapProvided = !string.IsNullOrWhiteSpace(_symbolMap); ICharacterModifier symbolModifier = null; if (symbolMapProvided) { symbolModifier = new CharacterSymbolModifier(_symbolMap); } var caseModifier = new CharacterCaseModifier(); foreach (var inputElement in _inputElements) { WordElement wordElement = new WordElement(inputElement.Key); Console.Write($"Word: '{inputElement.Key}'"); var characterModifiers = new List <ICharacterModifier>(); if (symbolMapProvided && inputElement.Value.SymbolVariation) { Console.Write(" + symbol substitution"); wordElement.AddCharacterModifier(symbolModifier); } if (inputElement.Value.CaseVariation) { Console.Write(" + case variation"); wordElement.AddCharacterModifier(caseModifier); } Console.Write(" ... "); wordElement.GenerateCharacterVariations(); Console.WriteLine($"{wordElement.Count} variants"); wordBank.AddWord(wordElement); } Console.WriteLine(); }
// Use this for initialization public void Start () { wordBank = new WordBank(); this.slots = GameObject.FindGameObjectsWithTag("WordBank"); RefillEmptyWords(); }
public WikiPage GetWikiPage(WordBank a_wordBank) { var wikiPage = _dbContext.WikiPages.FirstOrDefault(x => x.WordBankId == a_wordBank.WordBankId); return(wikiPage); }
// Use this for initialization void Start() { WordBank wordbank = WordBank.Instance; Debug.Log("wordbank contains Wonderful - " + wordbank.IsContaining("Wonderful")); }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new ApplicationDbContext(serviceProvider.GetRequiredService <DbContextOptions <ApplicationDbContext> >())) { if (context.Users.Any()) { return; } //seeding Users var seederUsers = new ApplicationUser[] { new ApplicationUser { Name = "Ron Swanson", Score = 6000, UserCPM = new List <UserCPM> { new UserCPM { CPM = 16 } } }, new ApplicationUser { Name = "Leslie Knope", Score = 5000, UserCPM = new List <UserCPM> { new UserCPM { CPM = 17 } } }, new ApplicationUser { Name = "Tom Haverford", Score = 2000, UserCPM = new List <UserCPM> { new UserCPM { CPM = 8 } } }, new ApplicationUser { Name = "Donna Meagle", Score = 4500, UserCPM = new List <UserCPM> { new UserCPM { CPM = 15 } } }, new ApplicationUser { Name = "Jerry Gergich", Score = 3500, UserCPM = new List <UserCPM> { new UserCPM { CPM = 13 } } }, new ApplicationUser { Name = "Chris Traeger", Score = 4000, UserCPM = new List <UserCPM> { new UserCPM { CPM = 14 } } }, new ApplicationUser { Name = "Ann Perkins", Score = 4000, UserCPM = new List <UserCPM> { new UserCPM { CPM = 15 } } }, new ApplicationUser { Name = "Andy Dwyer", Score = 500, UserCPM = new List <UserCPM> { new UserCPM { CPM = 10 } } }, new ApplicationUser { Name = "April Ludgate", Score = 2500, UserCPM = new List <UserCPM> { new UserCPM { CPM = 14 } } }, new ApplicationUser { Name = "Ben Wyatt", Score = 4500, UserCPM = new List <UserCPM> { new UserCPM { CPM = 13 } } } }; foreach (ApplicationUser u in seederUsers) { context.ApplicationUser.Add(u); } context.SaveChanges(); //seeding Words - Difficulty 1 var seederWords1 = new WordBank[] { new WordBank { Word = "GIT", Difficulty = 1 }, new WordBank { Word = "DOG", Difficulty = 1 }, new WordBank { Word = "BUS", Difficulty = 1 }, new WordBank { Word = "INT", Difficulty = 1 }, new WordBank { Word = "WHO", Difficulty = 1 }, new WordBank { Word = "SOY", Difficulty = 1 }, new WordBank { Word = "CAT", Difficulty = 1 }, new WordBank { Word = "PIT", Difficulty = 1 }, new WordBank { Word = "FLY", Difficulty = 1 }, new WordBank { Word = "ELF", Difficulty = 1 }, new WordBank { Word = "SPY", Difficulty = 1 }, }; foreach (WordBank w in seederWords1) { context.WordBank.Add(w); } context.SaveChanges(); //seeding Words - Difficulty 2 var seederWords2 = new WordBank[] { new WordBank { Word = "FIZZ", Difficulty = 2 }, new WordBank { Word = "BUZZ", Difficulty = 2 }, new WordBank { Word = "JUMP", Difficulty = 2 }, new WordBank { Word = "DOJO", Difficulty = 2 }, new WordBank { Word = "QUIZ", Difficulty = 2 }, new WordBank { Word = "HACK", Difficulty = 2 }, new WordBank { Word = "AQUA", Difficulty = 2 }, new WordBank { Word = "EXPO", Difficulty = 2 }, new WordBank { Word = "JOIN", Difficulty = 2 }, new WordBank { Word = "CART", Difficulty = 2 }, new WordBank { Word = "FLIP", Difficulty = 2 }, }; foreach (WordBank w in seederWords2) { context.WordBank.Add(w); } context.SaveChanges(); //seeding Words - Difficulty 3 var seederWords3 = new WordBank[] { new WordBank { Word = "SPLIT", Difficulty = 3 }, new WordBank { Word = "PIZZA", Difficulty = 3 }, new WordBank { Word = "QUICK", Difficulty = 3 }, new WordBank { Word = "JUMBO", Difficulty = 3 }, new WordBank { Word = "WALTZ", Difficulty = 3 }, new WordBank { Word = "BANJO", Difficulty = 3 }, new WordBank { Word = "JAPAN", Difficulty = 3 }, new WordBank { Word = "JUDGE", Difficulty = 3 }, new WordBank { Word = "PRIZE", Difficulty = 3 }, new WordBank { Word = "PICKY", Difficulty = 3 }, new WordBank { Word = "QUERY", Difficulty = 3 }, }; foreach (WordBank w in seederWords3) { context.WordBank.Add(w); } context.SaveChanges(); } }
private void Start() { _wordBank = new WordBank(_trainingPhrases); NextWord(); }