dbfilehelper.cs

来自「http://wordnet.princeton.edu/ WordNet i」· CS 代码 · 共 76 行

CS
76
字号
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace WordNetParser.Helpers
{
	internal class DbFileHelper
	{
		#region GetIndexForType
		internal static List<string> GetIndexForType( DbPartOfSpechType type )
		{
			List<string> retVal = new List<string>();

			if ( type == DbPartOfSpechType.All )
			{
				retVal.Add( GetDbIndexPath( DbPartOfSpechType.Adj ) );
				retVal.Add( GetDbIndexPath( DbPartOfSpechType.Adv ) );
				retVal.Add( GetDbIndexPath( DbPartOfSpechType.Noun ) );
				retVal.Add( GetDbIndexPath( DbPartOfSpechType.Verb ) );
			}
			else
			{
				retVal.Add( GetDbIndexPath( type ) );
			}

			return retVal;
		}
		#endregion GetIndexForType

		#region GetDBaseForType
		internal static List<string> GetDBaseForType( DbPartOfSpechType type )
		{
			List<string> retVal = new List<string>();

			if ( type == DbPartOfSpechType.All )
			{
				retVal.Add( GetDbDataPath( DbPartOfSpechType.Adj ) );
				retVal.Add( GetDbDataPath( DbPartOfSpechType.Adv ) );
				retVal.Add( GetDbDataPath( DbPartOfSpechType.Noun ) );
				retVal.Add( GetDbDataPath( DbPartOfSpechType.Verb ) );
			}
			else
			{
				retVal.Add( GetDbDataPath( type ) );
			}

			return retVal;
		}
		#endregion GetDBaseForType

		#region GetDbDataPath
		private static string GetDbDataPath( DbPartOfSpechType type )
		{
			return GetDbFilePath( DbType.Data, type );
		}
		#endregion GetDbDataPath

		#region GetDbIndexPath
		private static string GetDbIndexPath( DbPartOfSpechType type )
		{
			return GetDbFilePath( DbType.Index, type );
		}
		#endregion GetDbIndexPath

		#region GetDbFilePath
		private static string GetDbFilePath( DbType db, DbPartOfSpechType pos )
		{
			string filePath = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "Dict" );
			filePath = Path.Combine( filePath, string.Format( "{0}.{1}", db, pos ) );
			return filePath;
		}
		#endregion GetDbFilePath
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?