Skip to main content

Out of curiosity a port of love letter generator in c#

This is for my Harley-Queen(still waiting): this is a cook up code to tinker around:
 
using System;
using System.Text;
 
namespace LoveLetter
{
    internal class Program
    {
  static string NextRandomWord(string[] arr, Random rand) => arr[rand.Next(0, arr.Length)];
 
        private static void Main()
        {
            var salutation1 = new string[] { "Beloved", "Darling", "Dear",
          "Dearest", "Fanciful", "Honey" };
            var salutation2 = new string[] { "Chickpea", "Dear",
                      "Duck", "Jewel", "Love", "Moppet", "Sweetheart" };
            var adjs = new string[] { "affectionate", "amorous", "anxious",
            "avid", "beautiful", "breathless", "burning",
            "covetous", "craving", "curious", "eager", "fervent",
             "fondest", "loveable", "lovesick", "loving", "passionate",
           "precious", "seductive", "sweet", "sympathetic", "tender",
            "unsatisfied", "winning", "wistful" };
            var nouns = new string[] { "adoration", "affection", "ambition",
          "appetite", "ardour", "being", "burning", "charm", "craving",
           "desire", "devotion", "eagerness", "enchantment", "enthusiasm",
        "fancy", "fellow feeling", "fervour", "fondness", "heart", "hunger",
            "infatuation", "little liking", "longing", "love", "lust",
          "passion", "rapture", "sympathy", "thirst", "wish", "yearning" };
            var advs = new string[] { "affectionately", "ardently", "anxiously",
             "beautifully", "burningly", "covetously", "curiously",
        "eagerly", "fervently", "fondly", "impatiently", "keenly",
            "lovingly", "passionately", "seductively",
       "tenderly", "wistfully" };
            var verbs = new string[] { "adores", "attracts", "clings to",
             "holds dear", "hopes for", "hungers for", "likes",
       "longs for", "loves", "lusts after", "pants for", "pines for",
             "sighs for", "tempts", "thirsts for",
         "treasures", "yearns for", "woos" };
 
            int LONG = 1;
            int SHORT = 2;
            int? last = null;
            var rand = new Random();
            string ll;
            string concat = "";
            var builder = new StringBuilder();
            builder.Append($"{NextRandomWord(salutation1, rand)} 
                           { NextRandomWord(salutation2, rand)} \n");
            int numberOfLines = rand.Next(5, 7);
            for (var i = 0; i < numberOfLines; i++)
            {
                if (rand.Next(0, 9) < 5)
                {
                    //LONG
                    var optadj1 = (rand.Next(0, 9) < 5) ? "" : NextRandomWord(adjs, rand);
                    var noun1 = NextRandomWord(nouns, rand);
                    var optadv = (rand.Next(0, 9) < 5) ? "" : NextRandomWord(advs, rand);
                    var verb = NextRandomWord(verbs, rand);
                    var optadj2 = (rand.Next(0, 9) < 5) ? "" : NextRandomWord(adjs, rand);
                    var noun2 = NextRandomWord(nouns, rand);
                    if (last != null || last == LONG)
                    {
                        concat = ". ";
                    }
                    builder.Append($"{concat} My {optadj1} {noun1} {optadv} {verb} your 
                                     { optadj2}
                    { noun2}
                    ");
                    last = LONG;
                }
                else
                {
                    //SHORT
                    var adj = NextRandomWord(adjs, rand);
                    var noun = NextRandomWord(nouns, rand);
                    if (last == SHORT)
                    {
                        concat = ", ";
                    }
                    else if (last == LONG)
                    {
                        concat = ". You are";
                    }
                    else
                    {
                        concat = "You are ";
                    }
                    builder.Append($"{concat} my {adj} {noun}");
                    last = SHORT;
                }
            }
            ll = builder.ToString();
            var adv = NextRandomWord(advs, rand);
            ll += string.Format(".\n     Yours {0},\n     {1}.\n", adv, "Yourname");
            Console.WriteLine(ll);
            Console.ReadKey();
        }
    }
}

Comments

Popular posts from this blog

Interview experience

Recently,  I happen to attend interview for software engineer by a reputed engineering firm.  My recent career break made it harder for me to find some good job.  Earlier I want qualified for good job due to my education & now due to career break.  It seems like I'm also facing usual chicken and egg problem. But I find this shocking these industry people are basically concerned about knows language rather than knowing how to use the programming language &  effectively share ideas. I happen to observe certain interview sessions & facts going on while I was waiting in interviewing session room for my interview to happen Let me start with mine. It's always good to have a view about oneself before Judging others.  I passed two rounds of technicals &  was kicked out just by the first question in third round. And do you want to know what was that question? "Do you have worked using mfc???" Answered honestly as No.  & the reply I g...

Mission Accomplished

Due to certain circumstances the mission took a hard turn , moved from Thiruvananthapuram to Sandiago department, the main reason behind the shift is dataset and information availabilty of various factors such as twitter, drug stats, education etc etc. In short the project had been entitled as HYBRID APPROACH TO CRIME PREDICTION USING DEEP LEARNING. And below I will show you a glimpse of output which we got so far . this is so far away from the aim. Shows most probable location of crime on map on given unit time frame Probability of crime at a given hotspot The algorithm is far away from complete but its possible to construct one