| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Fire.Serialize.Annotations;
- namespace Leah.Speech.text {
- public class ContentEntry {
- public eMood Mood;
- public string Text;
- public List<ushort> _tags;
- public List<ushort> _optionalTags;
- public float Score; // TODO: Scoring einbauen
- #region Constructor
- public ContentEntry() {
- this.Text = "";
- this.Mood = eMood.All;
- this._tags = new List<ushort>();
- this._optionalTags = new List<ushort>();
- this.Score = 0.0f;
- }
- public ContentEntry(string Text) {
- this.Text = Text;
- this.Mood = eMood.All;
- this._tags = new List<ushort>();
- this._optionalTags = new List<ushort>();
- this.Score = 0.0f;
- }
- public ContentEntry(string Text, eMood Mood) {
- this.Text = Text;
- this.Mood = Mood;
- this._tags = new List<ushort>();
- this._optionalTags = new List<ushort>();
- this.Score = 0.0f;
- }
- public ContentEntry(string Text, eMood Mood, ushort[] Tags) {
- this.Text = Text;
- this.Mood = Mood;
- this._tags = new List<ushort>(Tags);
- this._optionalTags = new List<ushort>();
- this.Score = 0.0f;
- }
- public ContentEntry(string Text, float score) {
- this.Text = Text;
- this.Mood = eMood.All;
- this._tags = new List<ushort>();
- this._optionalTags = new List<ushort>();
- this.Score = score;
- }
- public ContentEntry(string Text, eMood Mood, float score) {
- this.Text = Text;
- this.Mood = Mood;
- this._tags = new List<ushort>();
- this._optionalTags = new List<ushort>();
- this.Score = score;
- }
- public ContentEntry(string Text, eMood Mood, ushort[] Tags, float score) {
- this.Text = Text;
- this.Mood = Mood;
- this._tags = new List<ushort>(Tags);
- this._optionalTags = new List<ushort>();
- this.Score = score;
- }
- #endregion
- #region Tag
- public void Tag_Add(ushort s) {
- if (!this._tags.Contains(s)) {
- this._tags.Add(s);
- }
- }
- public void Tag_Add(ushort[] s) {
- foreach (ushort t in s)
- this.Tag_Add(t);
- }
- public void Tag_Add(string tagString) {
- string[] itms = tagString.Split(new char[] { ',',';','|'});
- foreach(string itm in itms)
- if(itm.Length>0 && itm.Length<=5) {
- ushort f;
- if (ushort.TryParse(itm.Trim(), out f))
- this.Tag_Add(f);
- }
- }
- public void Tag_Remove(ushort tag) {
- this._tags.Remove(tag);
- }
- public void Tag_RemoveAt(ushort pos) {
- this._tags.RemoveAt(pos);
- }
- public void Tag_Clear() {
- this._tags.Clear();
- }
- [SerializeIgnore]
- public int Tag_Count {
- get {
- return this._tags.Count;
- }
- }
- public ushort[] Tags {
- get {
- return this._tags.ToArray();
- }
- set {
- this._tags = new List<ushort>(value);
- }
- }
- public bool Tag_Has(ushort tag) {
- return this._tags.Contains(tag);
- }
- public bool Tag_Has(ushort[] tags) {
- foreach (ushort t in tags)
- if (!this._tags.Contains(t))
- return false;
- return true;
- }
- #endregion
- #region OptionalTag
- public void OptionalTag_Add(ushort s) {
- if (!this._optionalTags.Contains(s)) {
- this._optionalTags.Add(s);
- }
- }
- public void OptionalTag_Add(ushort[] s) {
- foreach (ushort t in s)
- this.OptionalTag_Add(t);
- }
- public void OptionalTag_Add(string tagString) {
- string[] itms = tagString.Split(new char[] { ',', ';', '|' });
- foreach (string itm in itms)
- if (itm.Length > 0 && itm.Length <= 5) {
- ushort f;
- if (ushort.TryParse(itm.Trim(), out f))
- this.OptionalTag_Add(f);
- }
- }
- public void OptionalTag_Remove(ushort tag) {
- this._optionalTags.Remove(tag);
- }
- public void OptionalTag_RemoveAt(ushort pos) {
- this._optionalTags.RemoveAt(pos);
- }
- public void OptionalTag_Clear() {
- this._optionalTags.Clear();
- }
- [SerializeIgnore]
- public int OptionalTag_Count {
- get {
- return this._optionalTags.Count;
- }
- }
- public ushort[] OptionalTags {
- get {
- return this._optionalTags.ToArray();
- }
- set {
- this._optionalTags = new List<ushort>(value);
- }
- }
- public bool OptionalTag_Has(ushort tag) {
- return this._optionalTags.Contains(tag);
- }
- public bool OptionalTag_Has(ushort[] tags) {
- foreach (ushort t in tags)
- if (!this._optionalTags.Contains(t))
- return false;
- return true;
- }
- #endregion
-
-
- /*public string Text {
- get {
- return this._text;
- }
- set {
- this._text = value;
- }
- }*/
- /*public eMood Mood {
- get {
- return this._mood;
- }
- set {
- this._mood = value;
- }
- }*/
- /*public float Score {
- get {
- return this._score;
- }
- set {
- this._score = value;
- }
- }*/
- [SerializeIgnore]
- public string MoodText {
- get {
- return Contents.GetMoodString(this.Mood);
- }
- set {
- this.Mood = Contents.GetMood(value);
- }
- }
- public override string ToString() {
- return this.Text;
- }
- [SerializeIgnore]
- public string Tags_String {
- get {
- return String.Join(", ", this._tags.ToArray());
- }
- set {
- string s = value;
- string[] v = s.Split(new char[] { ',', ';', '|' });
- List<ushort> res = new List<ushort>();
- for (int i = 0, c = v.Length; i < c; i++) {
- v[i] = v[i].Trim();
- ushort j;
- if(ushort.TryParse(v[i],out j)) {
- res.Add(j);
- }
- }
- this._tags = res;
- }
- }
- [SerializeIgnore]
- public string OptionalTags_String {
- get {
- return String.Join(", ", this._optionalTags.ToArray());
- }
- set {
- string s = value;
- string[] v = s.Split(new char[] { ',', ';', '|' });
- List<ushort> res = new List<ushort>();
- for (int i = 0, c = v.Length; i < c; i++) {
- v[i] = v[i].Trim();
- ushort j;
- if (ushort.TryParse(v[i], out j)) {
- res.Add(j);
- }
- }
- this._optionalTags = res;
- }
- }
- }
- }
|