/// <summary> /// Creates a relation. /// </summary> /// <param name="name">The name of the Relation.</param> /// <param name="owner">The utterance that contains this relation.</param> internal Relation(string name, Utterance owner) { Name = name; Utterance = owner; Head = null; Tail = null; }
public override void Update(GameInfo gameInfo) { base.Update(gameInfo); List <Talk> talkList = gameInfo.TalkList; // talkListからCO,占い結果の抽出 for (int i = readTalkListNum; i < talkList.Count; i++) { Talk talk = talkList[i]; Utterance utterance = new Utterance(talk.Content); switch (utterance.Topic) { // カミングアウトの発話の場合 case Topic.COMINGOUT: agi.ComingoutMap[talk.Agent] = (Role)utterance.Role; if (utterance.Role == MyRole) { SetPlanningVoteAgent(); } break; } } readTalkListNum = talkList.Count; }
public void Update(DwarfTime Time) { if (speech != null) { Utterance utter = speech.Current; if (utter.SubSentence != null && utter.SubSentence != SpeechBubble.Text) { if (SpeakerAnimation.IsDone()) { SpeakerAnimation.Reset(); } SpeakerAnimation.Play(); SpeechBubble.Text = utter.SubSentence; SpeechBubble.Invalidate(); } speech.MoveNext(); } SpeakerAnimation.Update(Time, Timer.TimerMode.Real); var next = NextAction; NextAction = null; if (next != null) { next(this); } }
public virtual void setUtterance(Utterance utterance) { string text = Object.instancehelper_toString(utterance); FileInputStream @is = new FileInputStream(text); this.dataSource.setInputStream(@is, false); }
public async Task <ActionResult> Create(UtteranceManageVM vm) { Intents intent = intentService.GetIntentInfo(Convert.ToInt32(vm.Utterance.IntentIDX)); string authoringKey = ConfigurationManager.AppSettings["AuthoringKey"].ToString(); string appID = ConfigurationManager.AppSettings["LuisAppID"].ToString(); string appVersion = ConfigurationManager.AppSettings["AppVersion"].ToString(); string appHost = ConfigurationManager.AppSettings["LuisHost"].ToString(); vm.Utterance.IsUseYN = true; vm.Utterance.RegistUserID = "eddy"; //HttpContext.User.Identity.Name; vm.Utterance.RegistDate = DateTime.Now; vm.Utterance.ModifyUserID = "eddy"; //HttpContext.User.Identity.Name; vm.Utterance.ModifyDate = DateTime.Now; //LUIS 해당 인텐트에 발화메시지 등록처리 Example example = new Example(); example.IntentName = intent.IntentName; example.Text = vm.Utterance.Utterance; Utterance utterance = await LuisCreateUtterance(appID, appVersion, authoringKey, example); //발화메시지 DB저장 vm.Utterance.ExampleID = utterance.ExampleId; intentService.AddUtterance(vm.Utterance); return(RedirectToAction("List", "Utterance")); }
public static void Fetch(Utterance u) { DateTime?parsedDate; Match match = Regex.Match(u.Query, @"(?:(?:0?[0-9]|1[0-2]):[0-5][0-9] [ap]m|(?:[01][0-9]|2[0-3]):[0-5][0-9])", RegexOptions.IgnoreCase); if (match.Success) { parsedDate = DateTimeUtil.SetDatetimeEntities(match.Value, match.Index, u); u.Entity.Type = "date"; u.Entity.DateTime = parsedDate; u.Entity.EntityText = GetEntityText(parsedDate); } else { match = Regex.Match(u.Query, @"(?:(?:0?[0-9]|1[0-2]) [ap]m|(?:[01][0-9]|2[0-3]))", RegexOptions.IgnoreCase); if (match.Success) { parsedDate = DateTimeUtil.SetDatetimeEntities(match.Value.Insert(2, ":00"), match.Index, u); u.Entity.Type = "date"; u.Entity.DateTime = parsedDate; u.Entity.EntityText = GetEntityText(parsedDate); } } }
public override void initializeModels(string context) { this.dumpMemoryInfo("TrainManager start"); Iterator iterator = this.acousticModels.iterator(); while (iterator.hasNext()) { TrainerAcousticModel trainerAcousticModel = (TrainerAcousticModel)iterator.next(); this.controlFile.startUtteranceIterator(); while (this.controlFile.hasMoreUtterances()) { Utterance utterance = this.controlFile.nextUtterance(); this.initLearner.setUtterance(utterance); TrainerScore[] score; while ((score = this.initLearner.getScore()) != null) { if (!SimpleTrainManager.assertionsDisabled && score.Length != 1) { throw new AssertionError(); } trainerAcousticModel.accumulate(0, score); } } trainerAcousticModel.normalize(); } this.dumpMemoryInfo("acoustic model"); }
/// <summary> /// Creates a relation. /// </summary> /// <param name="name">The name of the Relation.</param> /// <param name="owner">The utterance that contains this relation.</param> internal Relation(string name, Utterance owner) { this.name = name; this.owner = owner; head = null; tail = null; }
public async Task <ActionResult> GetExampleData(string jsonText) { Utterance utterance = JsonConvert.DeserializeObject <Utterance>(jsonText); ViewBag.SyncOrAsync = "Asynchronous"; return(Json(await AddUtterances.ApiCall(jsonText), JsonRequestBehavior.AllowGet)); }
protected void AppendToPreviousUtterance(string text) { if (utterances.Count > 0) { Utterance utt = (Utterance)utterances [utterances.Count - 1]; utt.Text += "\n" + text; } }
static bool Meaning(Utterance utt, int num_nice_people) { // note scalar implicature: some _implies_ "not all" even // though logically some includes "all" return utt == Utterance.Some ? num_nice_people > 0 : utt == Utterance.All ? num_nice_people == 3 : utt == Utterance.Some ? num_nice_people == 0 : true; }
static bool Meaning(Utterance utt, int num_nice_people) { // note scalar implicature: some _implies_ "not all" even // though logically some includes "all" return(utt == Utterance.Some ? num_nice_people > 0 : utt == Utterance.All ? num_nice_people == 3 : utt == Utterance.Some ? num_nice_people == 0 : true); }
public static Uncertain <int> Listener(Utterance utt) { var program = from num_nice_people in WorldPrior() from stmt in Speaker(num_nice_people) where utt == stmt select num_nice_people; return(program.Inference()); }
public static Uncertain<int> LiteralListener(Utterance u) { var program = from num_nice_people in WorldPrior() let meaning = Meaning(u, num_nice_people) where meaning select num_nice_people; return program.Inference(); }
public static Uncertain<int> Listener(Utterance utt) { var program = from num_nice_people in WorldPrior() from stmt in Speaker(num_nice_people) where utt == stmt select num_nice_people; return program.Inference(); }
public static Uncertain <int> LiteralListener(Utterance u) { var program = from num_nice_people in WorldPrior() let meaning = Meaning(u, num_nice_people) where meaning select num_nice_people; return(program.Inference()); }
public override void Update(GameInfo gameInfo) { base.Update(gameInfo); List <Talk> talkList = gameInfo.TalkList; // talkListからCO,占い結果の抽出 for (int i = readTalkListNum; i < talkList.Count; i++) { Talk talk = talkList[i]; Utterance utterance = new Utterance(talk.Content); switch (utterance.Topic) { // カミングアウトの発話の場合 // 自分以外で占い師COするプレイヤーが出たら投票先を変える case Topic.COMINGOUT: agi.ComingoutMap[talk.Agent] = utterance.Role; if (utterance.Role == fakeRole) { SetPlanningVoteAgent(); } break; // 占い結果の発話の場合 // 人狼以外の占い,霊能結果で嘘だった場合は狂人だと判断 case Topic.DIVINED: // AGIのJudgeListに結果を加える Agent seerAgent = talk.Agent; Agent inspectedAgent = utterance.Target; Species inspectResult = (Species)utterance.Result; Judge judge = new Judge(Day, seerAgent, inspectedAgent, inspectResult); agi.AddInspectJudgeList(judge); // ジャッジしたのが人狼以外の場合 if (!WolfList.Contains(judge.Agent)) { Species judgeSpecies = judge.Result; Species realSpecies; if (WolfList.Contains(judge.Target)) { realSpecies = Species.WEREWOLF; } else { realSpecies = Species.HUMAN; } if (judgeSpecies != realSpecies) { maybePossesedAgent = judge.Agent; SetPlanningVoteAgent(); } } break; } } readTalkListNum = talkList.Count; }
public UtteranceHMMGraph(string context, Utterance utterance, AcousticModel acousticModel, UnitManager unitManager) { utterance.startTranscriptIterator(); while (utterance.hasMoreTranscripts()) { Transcript transcript = utterance.nextTranscript(); TranscriptHMMGraph transcriptGraph = new TranscriptHMMGraph(context, transcript, acousticModel, unitManager); this.add(transcriptGraph); } }
public static String SetResponse(Utterance u) { if (u.Entity["time"].Type != JTokenType.Null) if (u.Entity["entity"].Type != JTokenType.Null) return $"{_responses[_random.Next(_responses.Length)]} {u.Entity["entity"]}, {u.Entity["time"]}."; else return $"{_responses[_random.Next(_responses.Length)]} {u.Entity["time"]}."; else return _noEntityResponses[_random.Next(_noEntityResponses.Length)]; }
public static String SetResponse(Utterance u) { if (u.Entity["entity"].Type != JTokenType.Null) { return($"{_responses[_random.Next(_responses.Length)]} '{u.Entity["entity"]}'."); } else { return(_noEntityResponses[_random.Next(_noEntityResponses.Length)]); } }
public static String SetResponse(Utterance u) { Log.Logger.Information($"Response for utterance with code: {u.Code}. Determined to be PlaySong"); if (u.Entity["entity"].Type != JTokenType.Null) { return($"{_responses[_random.Next(_responses.Length)]} '{u.Entity["entity"]}'."); } else { return(_noEntityResponses[_random.Next(_noEntityResponses.Length)]); } }
public static void Fetch(Utterance u) { String intentName = u.TopScoringIntent.Name; intentName = intentName.First().ToString().ToUpper() + intentName.Substring(1); Type classType = Type.GetType("Starlight.EntityExtraction." + intentName); // The StartsWith("<>") is in there to avoid calling the '<>c__DisplayClass1_...' class from the Debugger, if this happens an 'NullReferenceException' will be thrown if (classType != null && classType.Name != "EntityExtractorController" && !classType.Name.StartsWith("<>")) { MethodInfo classMethod = classType.GetMethod("Fetch"); classMethod.Invoke(null, new object[] { u }); } }
public static DateTime?SetDatetimeEntities(String value, int index, Utterance u) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); DateTime parsedDate = DateTime.Parse(value); // If the time has already passed today, the alarm will be set for tomorrow. if (parsedDate.CompareTo(DateTime.Now) <= 0) { parsedDate = parsedDate.AddDays(1); } u.Entity.StartIndex = (byte)index; u.Entity.EndIndex = (byte)(index + 4); return(parsedDate); }
public virtual List expand(string text) { string inputText = this.simplifyChars(text); CharTokenizer charTokenizer = new CharTokenizer(); charTokenizer.setWhitespaceSymbols(" \t\n\r"); charTokenizer.setSingleCharSymbols(""); charTokenizer.setPrepunctuationSymbols("\"'`({["); charTokenizer.setPostpunctuationSymbols("\"'`.,:;!?(){}[]"); charTokenizer.setInputText(inputText); Utterance utterance = new Utterance(charTokenizer); Relation relation; if ((relation = utterance.getRelation("Token")) == null) { string text2 = "token relation does not exist"; throw new IllegalStateException(text2); } this.wordRelation = WordRelation.createWordRelation(utterance, this); this.tokenItem = relation.getHead(); while (this.tokenItem != null) { FeatureSet features = this.tokenItem.getFeatures(); string @string = features.getString("name"); this.tokenToWords(@string); this.tokenItem = this.tokenItem.getNext(); } ArrayList arrayList = new ArrayList(); for (Item item = utterance.getRelation("Word").getHead(); item != null; item = item.getNext()) { if (!String.instancehelper_isEmpty(item.toString())) { string text3 = item.toString(); object _ref = "#"; CharSequence charSequence = CharSequence.Cast(_ref); if (!String.instancehelper_contains(text3, charSequence)) { arrayList.add(item.toString()); } } } return(arrayList); }
public override void Update(GameInfo gameInfo) { base.Update(gameInfo); List <Talk> talkList = gameInfo.TalkList; bool existInspectResult = false; // talkListからCO,占い結果の抽出 for (int i = readTalkListNum; i < talkList.Count; i++) { Talk talk = talkList[i]; Utterance utterance = new Utterance(talk.Content); switch (utterance.Topic) { // カミングアウトの発話の場合 // 自分以外で占い師COするプレイヤーが出たら投票先を変える case Topic.COMINGOUT: agi.ComingoutMap[talk.Agent] = utterance.Role; if (utterance.Role == fakeRole) { SetPlanningVoteAgent(); } break; // 占い結果の発話の場合 case Topic.DIVINED: // AGIのJudgeListに結果を加える Agent seerAgent = talk.Agent; Agent inspectedAgent = utterance.Target; Species inspectResult = (Species)utterance.Result; Judge judge = new Judge(Day, seerAgent, inspectedAgent, inspectResult); agi.AddInspectJudgeList(judge); existInspectResult = true; break; } } readTalkListNum = talkList.Count; // 新しい占い結果があれば投票先を変える.(新たに黒判定が出た,または投票先のプレイヤーに白判定が出た場合) if (existInspectResult) { SetPlanningVoteAgent(); } }
public override void train() { if (!SimpleTrainManager.assertionsDisabled && this.controlFile == null) { throw new AssertionError(); } this.controlFile.startUtteranceIterator(); while (this.controlFile.hasMoreUtterances()) { Utterance utterance = this.controlFile.nextUtterance(); [email protected](utterance); utterance.startTranscriptIterator(); while (utterance.hasMoreTranscripts()) { [email protected](utterance.nextTranscript()); } } }
public static String SetResponse(Utterance u) { String intentName = u.TopScoringIntent.Name; intentName = intentName.First().ToString().ToUpper() + intentName.Substring(1); Type classType = Type.GetType("PolarisAICore.Response." + intentName); // The StartsWith("<>") is in there to avoid calling the '<>c__DisplayClass1_...' class from the Debugger, if this happens an 'NullReferenceException' will be thrown if (classType != null && classType.Name != "ResponseController" && !classType.Name.StartsWith("<>")) { MethodInfo classMethod = classType.GetMethod("SetResponse"); return((String)classMethod.Invoke(null, new object[] { u })); } else { return(null); } }
public static void Fetch(Utterance u) { List <String> queryArray = new List <string>(u.Query.Split(" ")); string[] entityTextArray = { }; if (queryArray.Contains("play")) { if (u.Query.Contains("play the music")) { entityTextArray = Util.EntityUtil.GetEntityTextArray(queryArray, "music", 1); u.Entity.EntityText = String.Join(" ", entityTextArray); } else if (u.Query.Contains("play the song")) { entityTextArray = Util.EntityUtil.GetEntityTextArray(queryArray, "song", 1); u.Entity.EntityText = String.Join(" ", entityTextArray); } else { entityTextArray = Util.EntityUtil.GetEntityTextArray(queryArray, "play", 1); u.Entity.EntityText = String.Join(" ", entityTextArray); } } if (u.Query.Contains("listen to") && !u.Query.Contains("listen to music")) { entityTextArray = Util.EntityUtil.GetEntityTextArray(queryArray, "to", 1); u.Entity.EntityText = String.Join(" ", entityTextArray); } else if (u.Query.Contains("listen to the music")) { entityTextArray = Util.EntityUtil.GetEntityTextArray(queryArray, "music", 1); u.Entity.EntityText = String.Join(" ", entityTextArray); } if (u.Entity.EntityText != String.Empty && u.Entity.EntityText != null) { u.Entity.Type = "music"; Util.EntityUtil.SetEntityIndexes(u, entityTextArray[0]); } }
protected void AddUtterance(DateTime timestamp, string who, string text) { Utterance utt = new Utterance(); utt.Timestamp = timestamp; utt.Who = who; utt.Text = text.Trim(); if (StartTime.Ticks == 0 || StartTime > timestamp) { StartTime = timestamp; } if (EndTime.Ticks == 0 || EndTime < timestamp) { EndTime = timestamp; } speakerHash [who] = true; utterances.Add(utt); }
private List <Tuple <Intent, double> > GetIntents(string text, string[] words) { List <Tuple <Intent, double> > list = new List <Tuple <Intent, double> >(); foreach (var intent in _model.Intents) { var utterances = _model.Utterances.Where(u => u.Intent.Equals(intent)); Utterance bestUtterance = null; int countMaxCommonWords = 0; foreach (var utt in utterances) { var keyWordsUtterances = GetKeywords(utt.Text); var listCommunWords = words.Join(keyWordsUtterances, o => o.ToLower(), i => i.ToLower(), (s, p) => p).ToList(); if (listCommunWords.Count > countMaxCommonWords) { bestUtterance = utt; countMaxCommonWords = listCommunWords.Count; } } if (bestUtterance == null) { list.Add(new Tuple <Intent, double>(intent, 0d)); } else { var results = _levenshteinCalculator.GetResults(text, bestUtterance.Text); double inverseResult = 100 - (results.Score / (text.Split(' ').Length * 1.0d)); inverseResult += countMaxCommonWords; double score = (inverseResult * 1) / 100d; score = score >= 1 ? 0.99 : score; list.Add(new Tuple <Intent, double>(intent, score)); } } return(list); }
public static void SetEntityIndexes(Utterance u, String entity) { u.Entity.StartIndex = (Byte)u.Query.IndexOf(entity); u.Entity.EndIndex = (Byte)(u.Query.Count() - 1); }
protected void AddUtterance (DateTime timestamp, string who, string text) { Utterance utt = new Utterance (); utt.Timestamp = timestamp; utt.Who = who; utt.Text = text.Trim (); if (StartTime.Ticks == 0 || StartTime > timestamp) StartTime = timestamp; if (EndTime.Ticks == 0 || EndTime < timestamp) EndTime = timestamp; speakerHash [who] = true; utterances.Add (utt); }
/// <summary> /// Creates a WordRelation object with the given utterance and TokenToWords. /// </summary> /// <param name="utterance">the Utterance from which to create a Relation.</param> /// <param name="tokenToWords">The TokenToWords object to use.</param> /// <returns>a WordRelation object</returns> public static WordRelation CreateWordRelation(Utterance utterance, UsEnglishTokenizer tokenToWords) { var relation = utterance.CreateRelation(Relation.Word); return(new WordRelation(relation, tokenToWords)); }
public static String SetResponse(Utterance u) { Log.Logger.Information($"Response for utterance with code: {u.Code}. Determined to be ShowWeather"); return(_noEntityResponses[_random.Next(_noEntityResponses.Length)]); }