/// <summary> /// setting the color of a "animal" object according to sentenceinformation /// </summary> /// <param name="si"> Sentenceinformationobject from grammar generation </param> public void ChangeColorTo(SentenceInformation si) { if (current.TryGetComponent <AnimalController>(out AnimalController ac)) { current.GetComponent <AnimalController>().CreateColor(si.Colour.name); } }
/// <summary> /// Is painting one object given by the gramar into the whole picture /// </summary> public void PaintPicture() { SentenceInformation si = grammars.GenerateSentence(); // group or single object spawning if (si.Singular == false) { int r = UnityEngine.Random.Range(2, 5); for (int i = 0; i < r; i++) { while (!PlaceObjectAt(si)) { si = grammars.GenerateSentence(); } } } else { while (!PlaceObjectAt(si)) { si = grammars.GenerateSentence(); } } ChangeActionTo(si); ChangeMoodTo(si); ChangePersonTo(si); ChangeColorTo(si); }
/// <summary> /// setting the assets of a "person" object to depict the type of person according to sentenceinformation. Information /// of related asset from MasterData.json file /// </summary> /// <param name="si"> Sentenceinformationobject from grammar generation </param> public void ChangePersonTo(SentenceInformation si) { if (current.TryGetComponent <AssetHolder>(out AssetHolder ah)) { StartCoroutine(SpawnAtEndOfFrame(si.Subject.asset, current, PositionAtCharacter.HATPOS)); //Debug.Log("setting texture"); current.GetComponent <CharacterController>().CreateMaterial(si.Subject.texture); } }
/// <summary> /// setting action (verb) of a "person" object according to sentenceinformation /// </summary> /// <param name="si"> Sentenceinformationobject from grammar generation </param> private void ChangeActionTo(SentenceInformation si) { //_renderHead = current.GetComponent<MeshRenderer>(); if (current.TryGetComponent(out AssetHolder ah)) { switch (si.Action.name) { case "musiziert": current.GetComponent <CharacterController>().LoadAndPlay(si.Action.animation); StartCoroutine(SpawnAtEndOfFrame("guitar", current, PositionAtCharacter.LEFTHAND)); break; case "singt": current.GetComponent <CharacterController>().LoadAndPlay(si.Action.animation); StartCoroutine(SpawnAtEndOfFrame("microphone", current, PositionAtCharacter.RIGHTHAND)); break; case "isst": case "schlemmt": case "nascht": current.GetComponent <CharacterController>().LoadAndPlay(si.Action.animation); StartCoroutine(SpawnAtEndOfFrame("pizza", current, PositionAtCharacter.RIGHTHAND)); break; case "malt": current.GetComponent <CharacterController>().LoadAndPlay(si.Action.animation); StartCoroutine(SpawnAtEndOfFrame("paintbrush", current, PositionAtCharacter.RIGHTHAND)); StartCoroutine(SpawnAtEndOfFrame("colourpalette", current, PositionAtCharacter.LEFTHAND)); break; case "läuft": current.GetComponent <CharacterController>().LoadAndPlay(si.Action.animation); break; case "wartet": current.GetComponent <CharacterController>().LoadAndPlay(si.Action.animation); break; case "überlegt": current.GetComponent <CharacterController>().LoadAndPlay(si.Action.animation); break; case "ist": current.GetComponent <CharacterController>().LoadAndPlay(si.Action.animation); break; default: current.GetComponent <CharacterController>().LoadAndPlay(si.Action.animation); if (!si.Action.model.Equals("prefab_path")) { StartCoroutine(SpawnAtEndOfFrame(si.Action.model, current, PositionAtCharacter.RIGHTHAND)); } break; } } }
private static bool MustContinue(SentenceInformation sentence, SentenceInformationDto sentenceInfoDto) { if (Helper.SentenceIsInvalid(sentenceInfoDto)) { return(true); } if (sentence.Dependencies.Count > 20 && !Helper.SentenceContainsYear(sentenceInfoDto)) { return(true); } return(false); }
public SentenceInformation GenerateSentence() { GetProbability(); si = new SentenceInformation(); si.Singular = true; //si.ClearInformation(); template = GetTemplate(); sentence = FillInTemplate(template); Helper.UpperCase(sentence); //Debug.Log(sentence); return(si); }
/// <summary> /// setting the facial texture of a "person" object according to sentenceinformation to depict the specified mood /// </summary> /// <param name="si"> Sentenceinformationobject from grammar generation </param> public void ChangeMoodTo(SentenceInformation si) { if (si.Subject.type == "person") { GameObject gameObject = current; //_renderHead = gameObject.GetComponentInChildren<Renderer>(); //generate mood if (si.Mood.textures != null) { //Debug.Log("looking for textures"); current.GetComponent <CharacterController>().CreateFaceMaterial(si.Mood.textures); } } }
public List <SentenceInformation> GetSentencesInformationFromJson(string filePath) { var jsonOutput = System.IO.File.ReadAllText(filePath); var joText = JObject.Parse(jsonOutput); var joSentences = (JArray)joText["sentences"]; var sentencesInformation = new List <SentenceInformation>(); foreach (var jToken in joSentences) { var sentence = (JObject)jToken; var sentenceProc = new SentenceProcessing(sentence); var sentenceInfo = new SentenceInformation(sentenceProc.GetSentenceText(), sentenceProc.GetDependencies(), sentenceProc.GetWordInformation()); sentencesInformation.Add(sentenceInfo); } return(sentencesInformation); }
private void ctlList_SelectedItemChanged(object sender, EventArgs e) { SentenceInformation sentenceInformation = ctlList.SelectedItem as SentenceInformation; if (sentenceInformation == null) { return; } if (txtSentence.Text.Length > sentenceInformation.Start) { txtSentence.SelectionStart = sentenceInformation.Start; } if (txtSentence.Text.Length > sentenceInformation.Start + sentenceInformation.Length) { txtSentence.SelectionLength = sentenceInformation.Length; } else { txtSentence.SelectionLength = txtSentence.Text.Length - txtSentence.SelectionStart; } }
private static IEnumerable <WordInformationDto> GetSentenceWords(SentenceInformation sentence) { return(sentence.Words.Select(w => new WordInformationDto(w.Word, w.PartOfSpeech, w.NamedEntityRecognition, w.Lemma)) .ToList()); }
private static IEnumerable <SentenceDependencyDto> GetSentenceDependency(SentenceInformation sentence) { return(sentence.Dependencies.Select(s => new SentenceDependencyDto(s.Dep, s.Governor, s.GovernorGloss, s.Dependent, s.DependentGloss)) .ToList()); }
/// <summary> /// seting location, scale and rotaion by sentenceinformationobject /// </summary> /// <param name="si"> Sentenceinformationobject from grammar generation </param> /// <returns> <see cref="System.Boolean"/> whether object could be placed or not</returns> private bool PlaceObjectAt(SentenceInformation si) { placed = false; Vector3 position; switch (si.Position) { case "links": case "vorne links": { position = positionController.GetLeft.position; break; } case "rechts": case "vorne rechts": { position = positionController.GetRight.position; break; } case "im Vordergrung": { position = positionController.GetForeground.position; break; } case "im Hintergrund": { position = positionController.GetBackground.position; break; } case "hinten links": { position = positionController.GetBackLeft.position; break; } case "hinten rechts": { position = positionController.GetBackRight.position; break; } case "unten": { position = positionController.GetDown.position; break; } default: { position = positionController.GetForeground.position; break; } } int max_iter = 1000; int iter = 0; while (iter < max_iter) //while, colliding generate new position and check if its working { Vector2 pv = UnityEngine.Random.insideUnitCircle * radius; Vector3 positionObject = new Vector3(pv.x, 0, pv.y) + position; GameObject gameObject = SpawnObject(si.Subject.model, positionObject, Quaternion.identity); current = gameObject; current.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f); Collider c = current.GetComponent <Collider>(); if (c != null) //check if object has collider { if (ValidateSpawn(c.bounds)) //check if object is intersecting with another object { Destroy(current); radius = radius + 0.1f; } else { colliderBounds.Add(c.bounds); placed = true; presentGameObjects.Add(current); break; } } else { Debug.LogError("Object has no Collider"); placed = false; break; } iter++; } //scaling if (si.Subject.scalable) { float randomX; randomX = current.transform.localScale.x * UnityEngine.Random.Range(0.8f, 1.15f); current.transform.localScale = Vector3.one * randomX; } //roatating if (si.Subject.rotatable) { float randomY = current.transform.rotation.eulerAngles.y + UnityEngine.Random.Range(-50, 50); current.transform.rotation = Quaternion.Euler(current.transform.rotation.x, randomY, current.transform.rotation.z); } return(placed); }