Beispiel #1
0
 static void Main(string[] args)
 {
     try
     {
         if (args.Length < 3)
         {
             OutputHelp();
         }
         else
         {
             string tbl_file_name = null, tg3_file_name = null, orange_file_name = null;
             if (ParseParams(args, ref m_verbose, ref tbl_file_name, ref tg3_file_name, ref orange_file_name))
             {
                 Verbose("Nalagam tabelo oznak ...\r\n");
                 MetaTaggerData.LoadAttributes(tbl_file_name);
                 Verbose("Nalagam učni korpus ...\r\n");
                 MetaTaggerData.LoadData(tg3_file_name);
                 Verbose("Pišem datoteko učnih primerov za Orange ...\r\n");
                 MetaTaggerData.WriteDatasetOrange(orange_file_name, /*null_val=*/ "0");
                 Verbose("Končano.\r\n");
             }
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine("*** Nepričakovana napaka. Podrobnosti: {0}\r\n{1}", exception, exception.StackTrace);
     }
 }
Beispiel #2
0
 static void Main(string[] args)
 {
     try
     {
         if (args.Length < 5)
         {
             OutputHelp();
         }
         else
         {
             string tags_1_file_name = null, tags_2_file_name = null, tbl_file_name = null, tree_file_name = null,
                    output_file_name = null;
             if (ParseParams(args, ref m_verbose, ref m_consistency_check, ref tags_1_file_name, ref tags_2_file_name,
                             ref tbl_file_name, ref tree_file_name, ref output_file_name))
             {
                 Verbose("Nalagam izhod prvega označevalnika ...\r\n");
                 Corpus corpus_1 = new Corpus();
                 corpus_1.LoadFromXml(tags_1_file_name, /*tag_len=*/ -1);
                 Verbose("Nalagam izhod drugega označevalnika ...\r\n");
                 Corpus corpus_2 = new Corpus();
                 corpus_2.LoadFromXml(tags_2_file_name, /*tag_len=*/ -1);
                 if (!m_consistency_check)
                 {
                     if (corpus_1.TaggedWords.Count != corpus_2.TaggedWords.Count)
                     {
                         Console.WriteLine("*** Napaka! Dolžini vhodnih korpusov se ne ujemata.");
                         return;
                     }
                 }
                 else
                 {
                     Verbose("Preverjam ujemanje besed v vhodnih korpusih ...\r\n");
                     for (int i = 0; i < corpus_1.TaggedWords.Count; i++)
                     {
                         if (corpus_1.TaggedWords[i].Word.ToLower() != corpus_2.TaggedWords[i].Word.ToLower())
                         {
                             Console.WriteLine("*** Napaka! Besede v vhodnih korpusih se ne ujemajo.");
                             return;
                         }
                     }
                 }
                 Verbose("Nalagam tabelo oznak ...\r\n");
                 MetaTaggerData.LoadAttributes(tbl_file_name);
                 Verbose("Nalagam odločitveno drevo ...\r\n");
                 Tree tree = new Tree(tree_file_name);
                 Verbose("Označujem besedilo ...\r\n");
                 MetaTaggerData.LoadTestData(corpus_1, corpus_2);
                 for (int i = 0; i < MetaTaggerData.Items.Count; i++)
                 {
                     if (MetaTaggerData.Items[i].Tag1 != MetaTaggerData.Items[i].Tag2)
                     {
                         ArrayList <KeyDat <string, string> > test_example = MetaTaggerData.CreateExample(i);
                         if (tree.Classify(test_example) != 1)
                         {
                             corpus_1.TaggedWords[i].Lemma = MetaTaggerData.Items[i].Lemma2;
                             corpus_1.TaggedWords[i].Tag   = MetaTaggerData.Items[i].Tag2;
                         }
                     }
                 }
                 Verbose("Pišem izhodno datoteko ...\r\n");
                 StreamWriter writer = new StreamWriter(output_file_name);
                 writer.Write(corpus_1.ToString("XML-MI"));
                 writer.Close();
                 Verbose("Končano.\r\n");
             }
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine("*** Nepričakovana napaka. Podrobnosti: {0}\r\n{1}", exception, exception.StackTrace);
     }
 }