コード例 #1
0
        /*--------------------------------------------------------------------------------------------*/
        private void SkipSpecialArtifactDuplicates(IEnumerable <List <ArtNode> > pDupSets)
        {
            Console.WriteLine("Skipping special duplicates...");

            var map = new Dictionary <string, ArtNode>();

            foreach (List <ArtNode> dups in pDupSets)
            {
                foreach (ArtNode an in dups)
                {
                    string key = an.Art.Name.ToLower() + "`|`" + an.Art.Note.ToLower();

                    if (!map.ContainsKey(key))
                    {
                        map.Add(key, an);
                        continue;
                    }

                    Console.WriteLine(" - " + key);
                    an.IsSkipped = true;
                    ++vSkipCount;

                    ArtNode an2 = map[key];

                    if (an.Node.SynSet.Id == an2.Node.SynSet.Id)
                    {
                        if (an.Node.SynSet.WordList.Count == 2)
                        {
                            an2.IsSkipped = true;
                            ++vSkipCount;
                        }
                        else
                        {
                            an2.Art.Name += " / " + an.Art.Name;
                            Console.WriteLine("    * Renamed: " +
                                              an2.Node.SynSet.Id + " | " + an2.Art.Name + " | " + an2.Art.Disamb);
                        }
                    }
                    else
                    {
                        Console.WriteLine("    * Keep: " +
                                          an2.Node.SynSet.Id + " | " + an2.Art.Name + " | " + an2.Art.Disamb);
                        Console.WriteLine("    * Skip: " +
                                          an.Node.SynSet.Id + " | " + an.Art.Name + " | " + an.Art.Disamb);
                    }
                }
            }

            Console.WriteLine("Skipped " + vSkipCount + " Artifacts");
        }
コード例 #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void BuildArtifacts()
        {
            foreach (SemanticNode n in vNodes.NodeList)
            {
                Synset        ss    = n.SynSet;
                List <string> words = ArtNode.GetWordList(ss);
                string        pos   = Stats.PartsOfSpeech[ss.PartOfSpeechId] + "";

                Artifact art = new Artifact();
                art.Name   = string.Join(" / ", (words.Count > 5 ? words.GetRange(0, 5) : words));
                art.Name   = ArtNode.TruncateString(art.Name, 128);
                art.Note   = ArtNode.TruncateString(pos + ": " + ss.Gloss, 256);
                art.Synset = ss;
                art.Word   = (words.Count == 1 ? ss.WordList[0] : null);
                vList.Add(new ArtNode {
                    Art = art, Node = n, Word = art.Word
                });

                if (art.Word != null)
                {
                    continue;
                }

                for (int i = 0; i < words.Count; ++i)
                {
                    Word w = ss.WordList[i];

                    art      = new Artifact();
                    art.Name = ArtNode.TruncateString(words[i], 128);
                    art.Note = ArtNode.TruncateString(pos + ": " + ss.Gloss, 256);
                    art.Word = w;
                    vList.Add(new ArtNode {
                        Art = art, Node = n, Word = art.Word, IsWord = true
                    });
                }
            }

            Console.WriteLine("Created " + vList.Count + " Artifacts");
        }