/// <summary> /// Button Logic that sets player name /// </summary> public void SetName() { TextChecker.CheckWithCallback(messageInputField.text, TextCheckMode.Nickname, checkResult => { switch (checkResult) { case TextCheckResult.Invalid_Censored: chatClient.PublishMessage(DEFAULT_CHANNEL_NAME, "<color=red>Player Name Change Failed : ***CENSORED!!!***</color>"); break; case TextCheckResult.Invalid_Length: chatClient.PublishMessage(DEFAULT_CHANNEL_NAME, "<color=red>Player Name Change Failed : Name is EMPTY!</color>"); break; case TextCheckResult.Invalid_RegEx: chatClient.PublishMessage(DEFAULT_CHANNEL_NAME, "<color=red>Player Name Change Failed : Only Alphabet, Korean, Numbers are allowed!</color>"); break; case TextCheckResult.Valid: default: chatClient.PublishMessage(DEFAULT_CHANNEL_NAME, "<color=yellow>Player Name Change Success : " + playerName + " -> " + messageInputField.text + "</color>"); playerName = messageInputField.text; break; } } ); }
private async void Button_Click(object sender, RoutedEventArgs e) { var selectedOptionFromComboBox = cbOptions.SelectedItem as ComboBoxTemplate; string textToBeSent = ExtractText(selectedOptionFromComboBox); if (!TextChecker.CheckIfTextIsFormedCorrectly(textToBeSent)) { MessageBox.Show("Input is not in correct format, it can not be empty, and it must contains some letters"); return; } IWebApiService webApi = new TextWebApi(configApiKeyName, "xasdasdASFASGAGADasdasfgads1231241afasfafas"); IWebApiService webApiWithoutToken = new TextWebApi(configApiKeyName, null); if (!webApi.ServiceRunning()) { MessageBox.Show("API is currently down"); return; } string respo = await webApi.GetResponseFromApi(textToBeSent); MessageBox.Show(respo); string responseWithoutToken = await webApiWithoutToken.GetResponseFromApi(textToBeSent); MessageBox.Show(responseWithoutToken); }
private void Awake() { // Text Filtering System - Init Text Checker TextAsset textAsset = Resources.Load <TextAsset>("CensoredWords"); if (textAsset != null) { TextChecker.Init(textAsset); } }
public static string GetJulietStageDirection(string s, float timeLapse) { if (timeLapse < 5) { if (Random.Range(0, 5) < 7) { if (Random.Range(0, 10) < 5) { return("hurriedly"); } return("without hesitation"); } } if (s.Contains("!")) { if (Random.Range(0, 10) < 9) { if (TextChecker.CheckYesContains(s)) { return("eagerly"); } return("energetically"); } } if (TextChecker.CheckIndifference(s)) { if (Random.Range(0, 10) < 7) { int rand = Random.Range(0, 5); if (rand == 0) { return("indifferently"); } else if (rand == 1) { return("callously"); } else if (rand == 2) { return("annoyed"); } else { return("coldly"); } } } return(""); }
/// <summary> /// Button Logic that sends message to Photon Chat /// </summary> public void SendMessage() { if (TextChecker.Check(messageInputField.text, TextCheckMode.Chat)) { chatClient.PublishMessage(DEFAULT_CHANNEL_NAME, "<color=red>Post Failed : ***CENSORED!!!***</color>"); } else { chatClient.PublishMessage(DEFAULT_CHANNEL_NAME, messageInputField.text); } messageInputField.text = string.Empty; }
public void TestOurChecker() { bool isFaulty = TextChecker.CheckIfTextIsFormedCorrectly(" "); Assert.AreEqual(false, isFaulty); string withoutLetters = "123123@##!@#"; Assert.AreEqual(false, TextChecker.CheckIfTextIsFormedCorrectly(withoutLetters)); string correctFormedText = "some text description"; Assert.AreEqual(true, TextChecker.CheckIfTextIsFormedCorrectly(correctFormedText)); }
private int CheckCasualConversation(string s) { if (TextChecker.CheckRosaline(s)) { return(1000); } else if (TextChecker.CheckBye(s)) { return(1007); } else if (TextChecker.CheckRobot(s)) { state = ConversationBlock.FateOrFreeWill; return(300); } return(-1); }
private bool ParseCodeLine(KeyWordType wordType, string line, Action <string> documentationAction) { var checker = new TextChecker(); var matches = checker.CheckText(wordType, line); if (matches.Count > 0) { foreach (Match val in matches) { documentationAction(val.Value); } return(true); } else { return(false); } }
public static void UpdateJulietEmotion(string s) { if (TextChecker.CheckIndifference(s)) { _enthusiasmLevel--; _indifferenceLevel++; } if (s.Contains("!")) { _enthusiasmLevel++; _indifferenceLevel--; } if (TextChecker.CheckYesContains(s)) { _enthusiasmLevel++; } if (TextChecker.CheckNo(s)) { _indifferenceLevel++; } }
public override bool Parse() { try { string sourceFileName = path; string destFileName = Path.Combine(way, "original_txt", name); var text = File.ReadAllText(sourceFileName); TextChecker.Check(text); File.WriteAllText(destFileName, text); resp.TDesc = new TextDesc { Path = destFileName, Name = name, CreatinDate = DateTime.Now }; JSONCreator.CreateJSON(new TextDesc { Path = destFileName, Name = name }); return(true); } catch (Exception e) { Trace.WriteLine(e.Message); return(false); } }
private void GetRomeoResponse(string s) { _currentRomeoResponse = GetRomeoBlock(1005); _currentRomeoStageDirection = ""; #region Introduction Blocks //INTRODUCTION SECTION======================================================================================= if (state == ConversationBlock.Introduction) { if (_blockState[state] == 0) { _currentRomeoResponse = GetRomeoBlock(2); //speak again bright angel _blockState[state] = 1; } //Introduction pool else if (_blockState[state] == 1) { if (CheckCasualConversation(s) >= 0) { _currentRomeoResponse = GetRomeoBlock(CheckCasualConversation(s)); } else if (s.ToLower().Contains("romeo romeo") || s.ToLower().Contains("wherefore") || _callLine) { _currentRomeoResponse = GetRomeoBlock(101); state = ConversationBlock.FamilyStuff; _blockState[state] = 1; } else if (TextChecker.CheckSupContains(s)) { //plot out sup if (_blockState[ConversationBlock.FamilyStuff] < 5) //TODO: CHANGE OUT 5 { //go to family things _currentRomeoResponse = GetRomeoBlock(100); //sad hours seem long _currentRomeoStageDirection = "somberly"; state = ConversationBlock.FamilyStuff; } } else if (TextChecker.CheckGreetingContains(s)) { _currentRomeoResponse = GetRomeoBlock(3); _blockState[state] = 2; } else if (TextChecker.CheckIndifference(s) || TextChecker.CheckNoContains(s) || s.ToLower().Contains("romeo")) { _currentRomeoResponse = GetRomeoBlock(400); state = ConversationBlock.YourEmotion; _blockState[state] = 0; } // else if() asking about identity //family region } else if (_blockState[state] == 2) { //go to family things _currentRomeoResponse = GetRomeoBlock(100); //sad hours seem long _currentRomeoStageDirection = "somberly"; state = ConversationBlock.FamilyStuff; } } //=========================================================================================================== #endregion #region Family Stuff Blocks //FAMILY SECTION======================================================================================= else if (state == ConversationBlock.FamilyStuff) { if (_blockState[state] == 0) { if (CheckCasualConversation(s) >= 0) { _currentRomeoResponse = GetRomeoBlock(CheckCasualConversation(s)); } else if (TextChecker.CheckWhyContains(s) || TextChecker.CheckIndifferenceContains(s) || _callLine) { //why do sad hours seem long? _currentRomeoResponse = GetRomeoBlock(101); _blockState[state] = 1; } } else if (_blockState[state] == 1) { if (CheckCasualConversation(s) >= 0) { _currentRomeoResponse = GetRomeoBlock(CheckCasualConversation(s)); //i know not how to tell thee who i am } else if (TextChecker.CheckWhyContains(s) || TextChecker.CheckIndifferenceContains(s) || s.ToLower().Contains("romeo") || s.ToLower().Contains("montague") || _callLine) { _currentRomeoResponse = GetRomeoBlock(102); // it is an enemy to thee, shall i tell thee? _blockState[state] = 2; } } else if (_blockState[state] == 2) { if (TextChecker.CheckWhyContains(s) || TextChecker.CheckIndifferenceContains(s) || s.ToLower().Contains("tear") || s.ToLower().Contains("romeo") || s.ToLower().Contains("montague") || _callLine) { _currentRomeoResponse = GetRomeoBlock(103); //montague _blockState[state] = 3; } } else if (_blockState[state] == 3) { if (TextChecker.CheckYesContains(s) || TextChecker.CheckIndifferenceContains(s) || _callLine) { _currentRomeoResponse = GetRomeoBlock(104); //what should i change my name to? _blockState[state] = 4; } else if (TextChecker.CheckNoContains(s)) { _currentRomeoResponse = GetRomeoBlock(175); _blockState[state] = 6; } } else if (_blockState[state] == 4) { RomeoName = "Romeo " + _julietRawResponse; _currentRomeoResponse = GetRomeoBlock(105); if (s.ToLower() == "capulet") //if the player input capulet { _currentRomeoResponse = GetRomeoBlock(150); } if (s.ToLower() == "montague") { _currentRomeoResponse = GetRomeoBlock(151); RomeoName = "Romeo"; } _currentRomeoResponse.ReplaceLine(0, _julietRawResponse + "?"); //new name? your kinsman will still kill me _blockState[state] = 5; } else if (_blockState[state] == 5) { _blockState[state] = 6; _currentRomeoResponse = GetRomeoBlock(106); } else if (_blockState[state] == 6) { if (TextChecker.CheckNoContains(s) || _callLine) { //no i am not a capulet _currentRomeoResponse = GetRomeoBlock(108); _currentRomeoStageDirection = "relieved"; _blockState[state] = 7; } else if (TextChecker.CheckYesContains(s)) { //yes, i am a capulet _currentRomeoResponse = GetRomeoBlock(107); state = ConversationBlock.JustChatting; _blockState[ConversationBlock.JustChatting] = 0; } } else if (_blockState[state] == 7) { JulietName = "Juliet " + _julietRawResponse; _currentRomeoResponse = GetRomeoBlock(109); _currentRomeoResponse.ReplaceLine(0, _julietRawResponse + "?"); //new name for juliet? state = ConversationBlock.JustChatting; _blockState[ConversationBlock.JustChatting] = 0; } } //=========================================================================================================== #endregion #region Fate of Free Will Blocks //FATE OR FREE WILL SECTION======================================================================================= else if (state == ConversationBlock.FateOrFreeWill) { if (_blockState[state] == 0) { if (TextChecker.CheckYesContains(s)) { _currentRomeoResponse = GetRomeoBlock(302); if (_blockState[ConversationBlock.FamilyStuff] < 5) { state = ConversationBlock.Introduction; } else { _blockState[ConversationBlock.JustChatting] = 0; state = ConversationBlock.JustChatting; } } else if (TextChecker.CheckNoContains(s)) { _currentRomeoResponse = GetRomeoBlock(301); if (_blockState[ConversationBlock.FamilyStuff] < 5) { state = ConversationBlock.Introduction; } else { _blockState[ConversationBlock.JustChatting] = 0; state = ConversationBlock.JustChatting; } } } } //=========================================================================================================== #endregion #region Chatting Blocks //CHATTING SECTION======================================================================================= else if (state == ConversationBlock.JustChatting) { if (CheckCasualConversation(s) >= 0) { _currentRomeoResponse = GetRomeoBlock(CheckCasualConversation(s)); } else if (TextChecker.CheckGreetingContains(s)) { _currentRomeoResponse = GetRomeoBlock(GetRandomCompliment()); } else { if (_blockState[ConversationBlock.FamilyStuff] < 5) //TODO: CHANGE OUT 5 { //go to family things _scene++; //ui.DisplaySceneName("Act I, Scene " + GetRomanNumeral(_scene)); _currentRomeoResponse = GetRomeoBlock(100); //sad hours seem long _currentRomeoStageDirection = "somberly"; state = ConversationBlock.FamilyStuff; } else if (_blockState[ConversationBlock.YourEmotion] < 2) { _scene++; //ui.DisplaySceneName("Act I, Scene " + GetRomanNumeral(_scene)); _currentRomeoResponse = GetRomeoBlock(400); state = ConversationBlock.YourEmotion; _blockState[state] = 0; } else { _currentRomeoResponse = GetRomeoBlock(1008); } } } //=========================================================================================================== #endregion #region In Love? Blocks //IN LOVE SECTION======================================================================================= else if (state == ConversationBlock.InLove) { if (_blockState[state] == 0) //romeo has just asked if juliet loves him { } } //=========================================================================================================== #endregion #region Your Emotions Blocks //IN LOVE SECTION======================================================================================= else if (state == ConversationBlock.YourEmotion) { if (_blockState[state] == 0) //romeo has just asked how juliet is doing { if (TextChecker.CheckBadContains(s)) { if (TextChecker.CheckBad(s)) { _blockState[state] = 1; _currentRomeoResponse = GetRomeoBlock(401); _currentRomeoStageDirection = "concerned"; _currentRomeoResponse.ReplaceLine(0, "Then I too am " + s); //shall i go on? } else { _blockState[state] = 1; _currentRomeoResponse = GetRomeoBlock(402); } } else if (TextChecker.CheckGoodContains(s) || _callLine) { _blockState[state] = 3; _currentRomeoResponse = GetRomeoBlock(405); } } else if (_blockState[state] == 1) { if (TextChecker.CheckYesContains(s) || _callLine) { _blockState[state] = 2; _currentRomeoResponse = GetRomeoBlock(403); //do u feel better? } else if (TextChecker.CheckNoContains(s)) { _blockState[state] = 3; _currentRomeoResponse = GetRomeoBlock(405); //do u feel better? } } else if (_blockState[state] == 2) //do u feel better? { if (TextChecker.CheckYesContains(s) || _callLine) { _blockState[state] = 3; _currentRomeoResponse = GetRomeoBlock(405); } else if (TextChecker.CheckNoContains(s)) { _blockState[state] = 3; _currentRomeoResponse = GetRomeoBlock(1008); } } else if (_blockState[state] == 3) { if (TextChecker.CheckNoContains(s)) { _currentRomeoResponse = GetRomeoBlock(406); _currentRomeoStageDirection = "devastated"; state = ConversationBlock.JustChatting; _blockState[ConversationBlock.JustChatting] = 0; } else if (TextChecker.CheckYesContains(s) || _callLine) { _currentRomeoResponse = GetRomeoBlock(404); state = ConversationBlock.JustChatting; _blockState[ConversationBlock.JustChatting] = 0; } } } //=========================================================================================================== #endregion _slipups++; if (_currentRomeoResponse.LineOfImportance != "") { _currentLineOfImportance = _currentRomeoResponse.LineOfImportance; _slipups = 0; } if (_slipups > 1) { Debug.Log(_currentRomeoResponse.FullText); _currentRomeoResponse = GetHelperRomeoBlock(_currentRomeoResponse.FullText); } ui.DisplayResponse(_currentRomeoResponse, _currentRomeoStageDirection); _callLine = false; }
private bool IsOCRedTextValid() { return(TextChecker.IsTextValid(_language, _ocredText)); }