Exemple #1
0
 // Completes the subjects of the inner Contents.
 void CompleteInnerSubject()
 {
     if (ContentList == null)
     {
         return;
     }
     ContentList = ContentList.Select(c =>
     {
         if (c.Subject == Agent.NONE)
         {
             if (Operator == Operator.INQUIRE || Operator == Operator.REQUEST)
             {
                 return(c.CopyAndReplaceSubject(Target));
             }
             if (Subject != Agent.NONE)
             {
                 return(c.CopyAndReplaceSubject(Subject));
             }
         }
         c.CompleteInnerSubject();
         return(c);
     }).ToList().AsReadOnly();
 }
Exemple #2
0
        // Normalize Text.
        void NormalizeText()
        {
            switch (Topic)
            {
            case Topic.DUMMY:
                Text = string.Empty;
                break;

            case Topic.Skip:
                Text = Talk.SKIP;
                break;

            case Topic.Over:
                Text = Talk.OVER;
                break;

            case Topic.AGREE:
            case Topic.DISAGREE:
                Text = (Subject == Agent.NONE ? "" : Subject == Agent.ANY ? "ANY " : $"{Subject.ToString()} ")
                       + string.Join(" ", new string[] {
                    Topic.ToString(),
                    Utterance is Whisper ? "WHISPER" : "TALK",
                    $"day{Utterance.Day}",
                    $"ID:{Utterance.Idx}"
                });
                break;

            case Topic.ESTIMATE:
            case Topic.COMINGOUT:
                Text = (Subject == Agent.NONE ? "" : Subject == Agent.ANY ? "ANY " : $"{Subject.ToString()} ")
                       + string.Join(" ", new string[] {
                    Topic.ToString(),
                    Target == Agent.NONE ? "ANY" : Target.ToString(),
                    Role.ToString()
                });
                break;

            case Topic.DIVINED:
            case Topic.IDENTIFIED:
                Text = (Subject == Agent.NONE ? "" : Subject == Agent.ANY ? "ANY " : $"{Subject.ToString()} ")
                       + string.Join(" ", new string[] {
                    Topic.ToString(),
                    Target == Agent.NONE ? "ANY" : Target.ToString(),
                    Result.ToString()
                });
                break;

            case Topic.ATTACK:
            case Topic.ATTACKED:
            case Topic.DIVINATION:
            case Topic.GUARD:
            case Topic.GUARDED:
            case Topic.VOTE:
            case Topic.VOTED:
                Text = (Subject == Agent.NONE ? "" : Subject == Agent.ANY ? "ANY " : $"{Subject.ToString()} ")
                       + string.Join(" ", new string[] {
                    Topic.ToString(),
                    Target == Agent.NONE ? "ANY" : Target.ToString(),
                });
                break;

            case Topic.OPERATOR:
                switch (Operator)
                {
                case Operator.REQUEST:
                case Operator.INQUIRE:
                    Text = (Subject == Agent.NONE ? "" : Subject == Agent.ANY ? "ANY " : $"{Subject.ToString()} ")
                           + string.Join(" ", new string[] {
                        Operator.ToString(),
                        Target == Agent.NONE ? "ANY" : Target.ToString(),
                        $"({(ContentList[0]?.Subject == Target ? StripSubject(ContentList[0].Text) : ContentList[0]?.Text)})"
                    });
                    break;

                case Operator.BECAUSE:
                case Operator.XOR:
                    Text = (Subject == Agent.NONE ? "" : Subject == Agent.ANY ? "ANY " : $"{Subject.ToString()} ")
                           + string.Join(" ", new string[] {
                        Operator.ToString(),
                        $"({(ContentList[0]?.Subject == Subject ? StripSubject(ContentList[0].Text) : ContentList[0]?.Text)})",
                        $"({(ContentList[1]?.Subject == Subject ? StripSubject(ContentList[1].Text) : ContentList[1]?.Text)})"
                    });
                    break;

                case Operator.AND:
                case Operator.OR:
                    Text = (Subject == Agent.NONE ? "" : Subject == Agent.ANY ? "ANY " : $"{Subject.ToString()} ")
                           + string.Join(" ", new string[] {
                        Operator.ToString(),
                        string.Join(" ", ContentList.Select(c => $"({(c.Subject == Subject ? StripSubject(c.Text) : c.Text)})").ToArray())
                    });
                    break;

                case Operator.NOT:
                    Text = (Subject == Agent.NONE ? "" : Subject == Agent.ANY ? "ANY " : $"{Subject.ToString()} ")
                           + string.Join(" ", new string[] {
                        Operator.ToString(),
                        $"({(ContentList[0].Subject == Subject ? StripSubject(ContentList[0].Text) : ContentList[0].Text)})"
                    });
                    break;

                case Operator.DAY:
                    Text = (Subject == Agent.NONE ? "" : Subject == Agent.ANY ? "ANY " : $"{Subject.ToString()} ")
                           + string.Join(" ", new string[] {
                        Operator.ToString(),
                        Day.ToString(),
                        $"({(ContentList[0].Subject == Subject ? StripSubject(ContentList[0].Text) : ContentList[0].Text)})"
                    });
                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }
        }