lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject svn commit: r1353213 - /incubator/lucene.net/trunk/src/core/Analysis/WordlistLoader.cs
Date Sat, 23 Jun 2012 23:12:04 GMT
Author: synhershko
Date: Sat Jun 23 23:12:01 2012
New Revision: 1353213

URL: http://svn.apache.org/viewvc?rev=1353213&view=rev
Log:
Removing redundant code

Modified:
    incubator/lucene.net/trunk/src/core/Analysis/WordlistLoader.cs

Modified: incubator/lucene.net/trunk/src/core/Analysis/WordlistLoader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/WordlistLoader.cs?rev=1353213&r1=1353212&r2=1353213&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/WordlistLoader.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/WordlistLoader.cs Sat Jun 23 23:12:01 2012
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-using System;
 using System.Collections.Generic;
 
 namespace Lucene.Net.Analysis
@@ -34,7 +33,7 @@ namespace Lucene.Net.Analysis
 		/// <returns> A HashSet with the file's words</returns>
 		public static ISet<string> GetWordSet(System.IO.FileInfo wordfile)
 		{
-			ISet<string> result = new HashSet<string>();
+			ISet<string> result;
 			System.IO.StreamReader reader = null;
 			try
 			{
@@ -59,7 +58,7 @@ namespace Lucene.Net.Analysis
 		/// <returns> A HashSet with the file's words</returns>
 		public static HashSet<string> GetWordSet(System.IO.FileInfo wordfile, System.String
comment)
 		{
-			HashSet<string> result = new HashSet<string>();
+			HashSet<string> result;
 			System.IO.StreamReader reader = null;
 			try
 			{
@@ -84,24 +83,17 @@ namespace Lucene.Net.Analysis
 		/// <returns>A HashSet with the reader's words</returns>
 		public static HashSet<string> GetWordSet(System.IO.TextReader reader)
 		{
-			HashSet<string> result = new HashSet<string>();
-			System.IO.TextReader br = null;
-			try
-			{
-				System.String word = null;
-				while ((word = reader.ReadLine()) != null)
-				{
-				    result.Add(word.Trim());
-				}
-			}
-			finally
+			var result = new HashSet<string>();
+
+			System.String word;
+			while ((word = reader.ReadLine()) != null)
 			{
-				if (br != null)
-					br.Close();
+				result.Add(word.Trim());
 			}
+
 			return result;
 		}
-		
+
 		/// <summary> Reads lines from a Reader and adds every non-comment line as an entry
to a HashSet (omitting
 		/// leading and trailing whitespace). Every line of the Reader should contain only
 		/// one word. The words need to be in lowercase if you make use of an
@@ -114,31 +106,24 @@ namespace Lucene.Net.Analysis
 		/// </param>
 		/// <returns> A HashSet with the reader's words
 		/// </returns>
-        public static HashSet<string> GetWordSet(System.IO.TextReader reader, System.String
comment)
+		public static HashSet<string> GetWordSet(System.IO.TextReader reader, System.String
comment)
 		{
-            HashSet<string> result = new HashSet<string>();
-			System.IO.StreamReader br = null;
-			try
+			var result = new HashSet<string>();
+
+			System.String word;
+			while ((word = reader.ReadLine()) != null)
 			{
-				System.String word = null;
-				while ((word = reader.ReadLine()) != null)
+				if (word.StartsWith(comment) == false)
 				{
-					if (word.StartsWith(comment) == false)
-					{
-					    result.Add(word.Trim());
-					}
+					result.Add(word.Trim());
 				}
 			}
-			finally
-			{
-				if (br != null)
-					br.Close();
-			}
+
 			return result;
 		}
-		
-		
-		
+
+
+
 		/// <summary> Reads a stem dictionary. Each line contains:
 		/// <c>word<b>\t</b>stem</c>
 		/// (i.e. two tab seperated words)
@@ -151,7 +136,7 @@ namespace Lucene.Net.Analysis
 		{
 			if (wordstemfile == null)
 				throw new System.NullReferenceException("wordstemfile may not be null");
-            Dictionary<string, string> result = new Dictionary<string, string>();
+            var result = new Dictionary<string, string>();
 			System.IO.StreamReader br = null;
 			System.IO.StreamReader fr = null;
 			try



Mime
View raw message