Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reviewed classification tests and made minor changes. Part of issue #259 #420

Merged
merged 2 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Lucene.Net.Attributes;
using Lucene.Net.Attributes;
using Lucene.Net.Util;
using NUnit.Framework;
using System;
Expand Down Expand Up @@ -111,7 +111,7 @@ public override void TestForPublicMembersNamedSize(Type typeFromTargetAssembly)
public override void TestForPublicMembersContainingNonNetNumeric(Type typeFromTargetAssembly)
{
base.TestForPublicMembersContainingNonNetNumeric(typeFromTargetAssembly);
}
}

[Test, LuceneNetSpecific]
[TestCase(typeof(Lucene.Net.Classification.KNearestNeighborClassifier))]
Expand All @@ -129,12 +129,12 @@ public override void TestForPublicMembersWithNullableEnum(Type typeFromTargetAss

// LUCENENET NOTE: This test is only for identifying members who were changed from
// ICollection, IList or ISet to IEnumerable during the port (that should be changed back)
//[Test, LuceneNetSpecific]
//[TestCase(typeof(Lucene.Net.Classification.KNearestNeighborClassifier))]
//public override void TestForMembersAcceptingOrReturningIEnumerable(Type typeFromTargetAssembly)
//{
// base.TestForMembersAcceptingOrReturningIEnumerable(typeFromTargetAssembly);
//}
[Test, LuceneNetSpecific]
[TestCase(typeof(Lucene.Net.Classification.KNearestNeighborClassifier))]
public override void TestForMembersAcceptingOrReturningIEnumerable(Type typeFromTargetAssembly)
{
base.TestForMembersAcceptingOrReturningIEnumerable(typeFromTargetAssembly);
}

[Test, LuceneNetSpecific]
[TestCase(typeof(Lucene.Net.Classification.KNearestNeighborClassifier))]
Expand Down
34 changes: 17 additions & 17 deletions src/Lucene.Net.Tests.Classification/Utils/DataSplitterTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Text;
using Lucene.Net.Analysis;
using Lucene.Net.Classification.Utils;
Expand Down Expand Up @@ -32,20 +32,20 @@ namespace Lucene.Net.Classification
*/
public class DataSplitterTest : Util.LuceneTestCase
{
private AtomicReader _originalIndex;
private RandomIndexWriter _indexWriter;
private AtomicReader originalIndex;
private RandomIndexWriter indexWriter;
private Directory _dir;
NightOwl888 marked this conversation as resolved.
Show resolved Hide resolved

private String _textFieldName = "text";
private String _classFieldName = "class";
private String _idFieldName = "id";
private String textFieldName = "text";
private String classFieldName = "class";
private String idFieldName = "id";

[SetUp]
public override void SetUp()
{
base.SetUp();
_dir = NewDirectory();
_indexWriter = new RandomIndexWriter(
indexWriter = new RandomIndexWriter(
#if FEATURE_INSTANCE_TESTDATA_INITIALIZATION
this,
#endif
Expand All @@ -62,38 +62,38 @@ public override void SetUp()
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(
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);
doc.Add(new Field(classFieldName, Random.toString(), ft));
indexWriter.AddDocument(doc, analyzer);
}

_indexWriter.Commit();
indexWriter.Commit();

_originalIndex = SlowCompositeReaderWrapper.Wrap(_indexWriter.GetReader());
originalIndex = SlowCompositeReaderWrapper.Wrap(indexWriter.GetReader());
}

[TearDown]
public override void TearDown()
{
_originalIndex.Dispose();
_indexWriter.Dispose();
originalIndex.Dispose();
indexWriter.Dispose();
_dir.Dispose();
base.TearDown();
}

[Test]
public void TestSplitOnAllFields()
{
AssertSplit(_originalIndex, 0.1, 0.1);
AssertSplit(originalIndex, 0.1, 0.1);
}


[Test]
public void TestSplitOnSomeFields()
{
AssertSplit(_originalIndex, 0.2, 0.35, _idFieldName, _textFieldName);
AssertSplit(originalIndex, 0.2, 0.35, idFieldName, textFieldName);
}

public static void AssertSplit(AtomicReader originalIndex, double testRatio, double crossValidationRatio, params string[] fieldNames)
Expand Down