Exemplo n.º 1
0
        private static void displayDictionary(PersonDictionary personDictionary)
        {
            foreach (KeyValuePair<string, Person> kvp in personDictionary)
            {
                Console.WriteLine("{0} {1}", kvp.Key, kvp.Value);
            }

            Console.WriteLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            PersonDictionary people = new PersonDictionary();

            people.Add("MH", new Person { FirstName = "Moe", LastName = "Howard" });
            people.Add("CH", new Person { FirstName = "Curley", LastName = "Howard" });
            people.Add("LF", new Person { FirstName = "Larry", LastName = "Fine" });

            Console.WriteLine("{0}\n\n", people["LF"]);

            displayDictionary(people);

            people.Remove("CH");

            displayDictionary(people);
        }
Exemplo n.º 3
0
        public static bool Recognition(LinkedList <Vertex> pWordSegResult, WordNet wordNetOptimum, WordNet wordNetAll)
        {
            LinkedList <EnumItem <Corpus.Tag.NR> > roleTagList = roleObserve(pWordSegResult);

            if (HanLP.Config.DEBUG)
            {
                StringBuilder sbLog = new StringBuilder();
                //Iterator<Vertex> iterator = pWordSegResult.iterator();
                foreach (EnumItem <Corpus.Tag.NR> nrEnumItem in roleTagList)
                {
                    sbLog.Append('[');
                    //sbLog.Append(iterator.next().realWord);
                    sbLog.Append(' ');
                    sbLog.Append(nrEnumItem);
                    sbLog.Append(']');
                }
                Console.WriteLine("人名角色观察:%s\n", sbLog.ToString());
            }
            List <Corpus.Tag.NR> nrList = viterbiComputeSimply(roleTagList);

            if (HanLP.Config.DEBUG)
            {
                StringBuilder sbLog = new StringBuilder();
                //Iterator<Vertex> iterator = pWordSegResult.iterator();
                sbLog.Append('[');
                foreach (Corpus.Tag.NR nr in nrList)
                {
                    //sbLog.Append(iterator.next().realWord);
                    sbLog.Append('/');
                    sbLog.Append(nr);
                    sbLog.Append(" ,");
                }
                if (sbLog.Length > 1)
                {
                    sbLog.Remove(sbLog.Length - 2, sbLog.Length);
                }
                sbLog.Append(']');
                Console.WriteLine("人名角色标注:%s\n", sbLog.ToString());
            }

            PersonDictionary.parsePattern(nrList, pWordSegResult, wordNetOptimum, wordNetAll);
            return(true);
        }
        static void SavePersonInfoInDictionary()
        {
            Dictionary <int, string> personDic = new Dictionary <int, string>();
            PersonDictionary         ps        = new PersonDictionary(name: "Lars Landkort", 22);

            personDic.Add(ps.age, ps.name);

            foreach (var person in personDic)
            {
                Console.WriteLine($"Navn: {person.Value} Alder: {person.Key} fra dictionary");
                Console.WriteLine("---------------");
            }


            Dictionary <PersonDictionary, string> dictionaryWithPerson = new Dictionary <PersonDictionary, string>();

            dictionaryWithPerson.Add(new PersonDictionary("Hans Lange Lem", 32), "Bare nej");

            foreach (var dicPerson in dictionaryWithPerson)
            {
                Console.WriteLine($"Value: {dicPerson.Value} Key: {dicPerson.Key} fra Dictionary med Person som key");
            }
        }
Exemplo n.º 5
0
 public void Initialize()
 {
     _personDictionary = new PersonDictionary();
 }