lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [3/3] lucenenet git commit: formatting
Date Wed, 24 Dec 2014 22:43:56 GMT
formatting


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/b5568a32
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/b5568a32
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/b5568a32

Branch: refs/heads/master
Commit: b5568a32097a0ea06c7670b808e163c1f225e7e0
Parents: 3134b63
Author: Laimonas Simutis <laimis@gmail.com>
Authored: Tue Dec 23 21:43:22 2014 -0500
Committer: Laimonas Simutis <laimis@gmail.com>
Committed: Tue Dec 23 21:43:22 2014 -0500

----------------------------------------------------------------------
 .../Utils/DataSplitterTest.cs                   | 203 ++++++++++---------
 1 file changed, 102 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b5568a32/src/Lucene.Net.Tests.Classification/Utils/DataSplitterTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Classification/Utils/DataSplitterTest.cs b/src/Lucene.Net.Tests.Classification/Utils/DataSplitterTest.cs
index 637f12d..792b268 100644
--- a/src/Lucene.Net.Tests.Classification/Utils/DataSplitterTest.cs
+++ b/src/Lucene.Net.Tests.Classification/Utils/DataSplitterTest.cs
@@ -1,3 +1,4 @@
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -26,120 +27,120 @@ using NUnit.Framework;
 
 namespace Lucene.Net.Classification
 {
-/**
- * Testcase for {@link org.apache.lucene.classification.utils.DatasetSplitter}
- */
-    public class DataSplitterTest : Util.LuceneTestCase 
+    /**
+     * Testcase for {@link org.apache.lucene.classification.utils.DatasetSplitter}
+     */
+    public class DataSplitterTest : Util.LuceneTestCase
     {
-      private AtomicReader _originalIndex;
-      private RandomIndexWriter _indexWriter;
-      private Directory _dir;
-
-      private String _textFieldName = "text";
-      private String _classFieldName = "class";
-      private String _idFieldName = "id";
-
-      [SetUp]
-      public override void SetUp()
-      {
-        base.SetUp();
-        _dir = NewDirectory();
-        _indexWriter = new RandomIndexWriter(Random(), _dir, new MockAnalyzer(Random()));
-
-        FieldType ft = new FieldType(TextField.TYPE_STORED);
-        ft.StoreTermVectors = true;
-        ft.StoreTermVectorOffsets = true;
-        ft.StoreTermVectorPositions = true;
-
-        Analyzer analyzer = new MockAnalyzer(Random());
-
-        Document doc;
-        for (int i = 0; i < 100; i++) 
-        {
-          doc = new Document();
-          doc.Add(new Field(_idFieldName, Random().toString(), ft));
-          doc.Add(new Field(_textFieldName, new StringBuilder(Random().toString()).append(Random().toString()).append(
-              Random().toString()).toString(), ft));
-          doc.Add(new Field(_classFieldName, Random().toString(), ft));
-          _indexWriter.AddDocument(doc, analyzer);
-        }
+        private AtomicReader _originalIndex;
+        private RandomIndexWriter _indexWriter;
+        private Directory _dir;
 
-        _indexWriter.Commit();
+        private String _textFieldName = "text";
+        private String _classFieldName = "class";
+        private String _idFieldName = "id";
 
-        _originalIndex = SlowCompositeReaderWrapper.Wrap(_indexWriter.Reader);
-      }
-
-      [TearDown]
-      public override void TearDown()
-      {
-        _originalIndex.Dispose();
-        _indexWriter.Dispose();
-        _dir.Dispose();
-        base.TearDown();
-      }
-
-      [Test]
-      public void TestSplitOnAllFields() 
-      {
-        AssertSplit(_originalIndex, 0.1, 0.1);
-      }
+        [SetUp]
+        public override void SetUp()
+        {
+            base.SetUp();
+            _dir = NewDirectory();
+            _indexWriter = new RandomIndexWriter(Random(), _dir, new MockAnalyzer(Random()));
+
+            FieldType ft = new FieldType(TextField.TYPE_STORED);
+            ft.StoreTermVectors = true;
+            ft.StoreTermVectorOffsets = true;
+            ft.StoreTermVectorPositions = true;
+
+            Analyzer analyzer = new MockAnalyzer(Random());
+
+            Document doc;
+            for (int i = 0; i < 100; i++)
+            {
+                doc = new Document();
+                doc.Add(new Field(_idFieldName, Random().toString(), ft));
+                doc.Add(new Field(_textFieldName, new StringBuilder(Random().toString()).append(Random().toString()).append(
+                    Random().toString()).toString(), ft));
+                doc.Add(new Field(_classFieldName, Random().toString(), ft));
+                _indexWriter.AddDocument(doc, analyzer);
+            }
+
+            _indexWriter.Commit();
+
+            _originalIndex = SlowCompositeReaderWrapper.Wrap(_indexWriter.Reader);
+        }
 
+        [TearDown]
+        public override void TearDown()
+        {
+            _originalIndex.Dispose();
+            _indexWriter.Dispose();
+            _dir.Dispose();
+            base.TearDown();
+        }
 
-      [Test]
-      public void TestSplitOnSomeFields() 
-      {
-        AssertSplit(_originalIndex, 0.2, 0.35, _idFieldName, _textFieldName);
-      }
+        [Test]
+        public void TestSplitOnAllFields()
+        {
+            AssertSplit(_originalIndex, 0.1, 0.1);
+        }
 
-      public static void AssertSplit(AtomicReader originalIndex, double testRatio, double
crossValidationRatio, params string[] fieldNames) 
-      {
-        BaseDirectoryWrapper trainingIndex = NewDirectory();
-        BaseDirectoryWrapper testIndex = NewDirectory();
-        BaseDirectoryWrapper crossValidationIndex = NewDirectory();
 
-        try 
+        [Test]
+        public void TestSplitOnSomeFields()
         {
-          DatasetSplitter datasetSplitter = new DatasetSplitter(testRatio, crossValidationRatio);
-          datasetSplitter.Split(originalIndex, trainingIndex, testIndex, crossValidationIndex,
new MockAnalyzer(Random()), fieldNames);
-
-          NotNull(trainingIndex);
-          NotNull(testIndex);
-          NotNull(crossValidationIndex);
-
-          DirectoryReader trainingReader = DirectoryReader.Open(trainingIndex);
-          True((int) (originalIndex.MaxDoc * (1d - testRatio - crossValidationRatio)) ==
trainingReader.MaxDoc);
-          DirectoryReader testReader = DirectoryReader.Open(testIndex);
-          True((int) (originalIndex.MaxDoc * testRatio) == testReader.MaxDoc);
-          DirectoryReader cvReader = DirectoryReader.Open(crossValidationIndex);
-          True((int) (originalIndex.MaxDoc * crossValidationRatio) == cvReader.MaxDoc);
-
-          trainingReader.Dispose();
-          testReader.Dispose();
-          cvReader.Dispose();
-          CloseQuietly(trainingReader);
-          CloseQuietly(testReader);
-          CloseQuietly(cvReader);
-        } 
-        finally 
-        {
-          trainingIndex.Dispose();
-          testIndex.Dispose();
-          crossValidationIndex.Dispose();
+            AssertSplit(_originalIndex, 0.2, 0.35, _idFieldName, _textFieldName);
         }
-      }
 
-      private static void CloseQuietly(IndexReader reader)
-      {
-        try 
+        public static void AssertSplit(AtomicReader originalIndex, double testRatio, double
crossValidationRatio, params string[] fieldNames)
         {
-          if (reader != null)
-            reader.Dispose();
-        } 
-        catch (Exception e) 
+            BaseDirectoryWrapper trainingIndex = NewDirectory();
+            BaseDirectoryWrapper testIndex = NewDirectory();
+            BaseDirectoryWrapper crossValidationIndex = NewDirectory();
+
+            try
+            {
+                DatasetSplitter datasetSplitter = new DatasetSplitter(testRatio, crossValidationRatio);
+                datasetSplitter.Split(originalIndex, trainingIndex, testIndex, crossValidationIndex,
new MockAnalyzer(Random()), fieldNames);
+
+                NotNull(trainingIndex);
+                NotNull(testIndex);
+                NotNull(crossValidationIndex);
+
+                DirectoryReader trainingReader = DirectoryReader.Open(trainingIndex);
+                True((int)(originalIndex.MaxDoc * (1d - testRatio - crossValidationRatio))
== trainingReader.MaxDoc);
+                DirectoryReader testReader = DirectoryReader.Open(testIndex);
+                True((int)(originalIndex.MaxDoc * testRatio) == testReader.MaxDoc);
+                DirectoryReader cvReader = DirectoryReader.Open(crossValidationIndex);
+                True((int)(originalIndex.MaxDoc * crossValidationRatio) == cvReader.MaxDoc);
+
+                trainingReader.Dispose();
+                testReader.Dispose();
+                cvReader.Dispose();
+                CloseQuietly(trainingReader);
+                CloseQuietly(testReader);
+                CloseQuietly(cvReader);
+            }
+            finally
+            {
+                trainingIndex.Dispose();
+                testIndex.Dispose();
+                crossValidationIndex.Dispose();
+            }
+        }
+
+        private static void CloseQuietly(IndexReader reader)
         {
-          // do nothing
+            try
+            {
+                if (reader != null)
+                    reader.Dispose();
+            }
+            catch (Exception e)
+            {
+                // do nothing
+            }
         }
-      }
     }
 
 }
\ No newline at end of file


Mime
View raw message