コード例 #1
0
        public void TestAccuracy()
        {
            int correct = 0, total = 0;
            var mostFrequentTreeAutoSemantic = new MostFrequentTreeAutoSemantic(wordNet, fsm);
            var treeBank1 = new TreeBankDrawable("../../../new-trees/");
            var treeBank2 = new TreeBankDrawable("../../../old-trees/");

            for (var i = 0; i < treeBank1.Size(); i++)
            {
                var parseTree1 = treeBank1.Get(i);
                var parseTree2 = treeBank2.Get(i);
                mostFrequentTreeAutoSemantic.AutoSemantic(parseTree1);
                var nodeDrawableCollector1 =
                    new NodeDrawableCollector((ParseNodeDrawable)parseTree1.GetRoot(), new IsTurkishLeafNode());
                var leafList1 = nodeDrawableCollector1.Collect();
                var nodeDrawableCollector2 =
                    new NodeDrawableCollector((ParseNodeDrawable)parseTree2.GetRoot(), new IsTurkishLeafNode());
                var leafList2 = nodeDrawableCollector2.Collect();
                for (var j = 0; j < leafList1.Count; j++)
                {
                    total++;
                    var parseNode1 = leafList1[j];
                    var parseNode2 = leafList2[j];
                    if (parseNode1.GetLayerData(ViewLayerType.SEMANTICS) != null && parseNode1
                        .GetLayerData(ViewLayerType.SEMANTICS).Equals(parseNode2.GetLayerData(ViewLayerType.SEMANTICS)))
                    {
                        correct++;
                    }
                }
            }

            Assert.AreEqual(475, total);
            Assert.AreEqual(260, correct);
        }
コード例 #2
0
 /**
  * <summary> Constructor for the DataSetGenerator which takes input the data directory, the pattern for the training files
  * included, includePunctuation, and an instanceGenerator. The constructor loads the treeBank from the given directory
  * including the given files having the given pattern. If punctuations are not included, they are removed from
  * the data.</summary>
  * <param name="directory">Directory where the treeBank files reside.</param>
  * <param name="pattern">Pattern of the tree files to be included in the treeBank. Use "." for all files.</param>
  * <param name="includePunctuation">If true, punctuation symbols are also included in the dataset, false otherwise.</param>
  * <param name="instanceGenerator">The instance generator used to generate the dataSet.</param>
  */
 public DataSetGenerator(string directory, string pattern, bool includePunctuation,
                         InstanceGenerator.InstanceGenerator instanceGenerator)
 {
     _treeBank = new TreeBankDrawable(directory, pattern);
     this.instanceGenerator = instanceGenerator;
     if (!includePunctuation)
     {
         _treeBank.StripPunctuation();
     }
 }
コード例 #3
0
 /**
  * <summary> Constructor for the DisambiguationCorpusGenerator which takes input the data directory and the pattern for the
  * training files included. The constructor loads the treebank from the given directory including the given files
  * having the given pattern.</summary>
  *
  * <param name="directory">Directory where the treebank files reside.</param>
  * <param name="pattern">Pattern of the tree files to be included in the treebank. Use "." for all files.</param>
  */
 public TreeDisambiguationCorpusGenerator(string directory, string pattern)
 {
     _treeBank = new TreeBankDrawable(directory, pattern);
 }
コード例 #4
0
 public ConstituencyToDependencyTreeBank(TreeBankDrawable treeBank)
 {
     _treeBank = treeBank;
 }
コード例 #5
0
 /**
  * <summary> Constructor for the NERCorpusGenerator which takes input the data directory and the pattern for the training files
  * included. The constructor loads the treebank from the given directory including the given files having the given
  * pattern.</summary>
  *
  * <param name="directory">Directory where the treebank files reside.</param>
  * <param name="pattern">Pattern of the tree files to be included in the treebank. Use "." for all files.</param>
  */
 public NERCorpusGenerator(string directory, string pattern)
 {
     _treeBank = new TreeBankDrawable(directory, pattern);
 }