private class Node
{
public T Value { get; private set; }
-
- public int ChiledsCount { get; private set; }
-
+ public int ChildsCount { get; private set; }
public Node FirstChild { get; private set; }
-
public Node LastChild { get; private set; }
-
public Node Prev { get; private set; }
-
public Node Next { get; private set; }
public void AddFirstChild(Node first)
{
- this.ChiledsCount++;
- if (this.ChiledsCount == 1)
+ this.ChildsCount++;
+ if (this.ChildsCount == 1)
{
this.LastChild = first;
}
public void AddLastChild(Node last)
{
- this.ChiledsCount++;
- if (this.ChiledsCount == 1)
+ this.ChildsCount++;
+ if (this.ChildsCount == 1)
{
this.FirstChild = last;
}
public Node PollFirstChild()
{
- this.ChiledsCount--;
- if (this.ChiledsCount == 0)
+ this.ChildsCount--;
+ if (this.ChildsCount == 0)
{
this.LastChild.Prev = null;
this.LastChild = null;
private Node Unify(Node node)
{
- if (node == null || node.ChiledsCount == 0) return null;
+ if (node == null || node.ChildsCount == 0) return null;
- Node[] tmp = new Node[node.ChiledsCount / 2]; //擬似的Stack
+ Node[] tmp = new Node[node.ChildsCount / 2]; //必要な要素数が明らかなのでStackではなく配列
for (int i = 0; i < tmp.Length; i++)
{
}
Node z;
- if (node.ChiledsCount == 1)
+ if (node.ChildsCount == 1) //子要素数が奇数の場合、まだ1つ残っている子要素をここで処理
z = node.PollFirstChild();
else
z = null;
- for (int i = tmp.Length - 1; i >= 0; i--)
+ for (int i = tmp.Length - 1; i >= 0; i--) //逆順ループで配列をStackのように振る舞わせる
{
z = this.Merge(tmp[i], z);
}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{B5C3DDEA-F7CE-4A9D-8B28-5FC1B582A4EB}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>NMeCab</RootNamespace>
- <AssemblyName>LibNMeCab</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;MMF MMF_DIC MMF_MTX EXT</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>MMF MMF_DIC MMF_MTX</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="..\LibNMeCab\Core\BitUtils.cs">
- <Link>Core\BitUtils.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\CharInfo.cs">
- <Link>Core\CharInfo.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\CharProperty.cs">
- <Link>Core\CharProperty.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\Connector.cs">
- <Link>Core\Connector.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\DoubleArray.cs">
- <Link>Core\DoubleArray.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\IniParser.cs">
- <Link>Core\IniParser.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\MeCabDictionary.cs">
- <Link>Core\MeCabDictionary.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\MeCabPath.cs">
- <Link>Core\MeCabPath.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\NBestGenerator.cs">
- <Link>Core\NBestGenerator.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\PriorityQueue.cs">
- <Link>Core\PriorityQueue.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\StrUtils.cs">
- <Link>Core\StrUtils.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\Token.cs">
- <Link>Core\Token.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\Tokenizer.cs">
- <Link>Core\Tokenizer.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\Utils.cs">
- <Link>Core\Utils.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\Viterbi.cs">
- <Link>Core\Viterbi.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Core\Writer.cs">
- <Link>Core\Writer.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Extension\FeatureExtension.cs">
- <Link>Extension\FeatureExtension.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Extension\IpaDic\IpaDicFeatureExtension.cs">
- <Link>Extension\IpaDic\IpaDicFeatureExtension.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Extension\UniDic\UniDicFeatureExtension.cs">
- <Link>Extension\UniDic\UniDicFeatureExtension.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\MeCabDictionaryType.cs">
- <Link>MeCabDictionaryType.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\MeCabException.cs">
- <Link>MeCabException.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\MeCabFileFormatException.cs">
- <Link>MeCabFileFormatException.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\MeCabInvalidFileException.cs">
- <Link>MeCabInvalidFileException.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\MeCabLatticeLevel.cs">
- <Link>MeCabLatticeLevel.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\MeCabNode.cs">
- <Link>MeCabNode.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\MeCabNodeStat.cs">
- <Link>MeCabNodeStat.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\MeCabParam.cs">
- <Link>MeCabParam.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\MeCabTagger.cs">
- <Link>MeCabTagger.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Properties\Settings.Designer.cs">
- <Link>Properties\Settings.Designer.cs</Link>
- <AutoGen>True</AutoGen>
- <DesignTimeSharedInput>True</DesignTimeSharedInput>
- </Compile>
- <Compile Include="..\LibNMeCab\Properties\SharedAssemblyInfo.cs">
- <Link>Properties\SharedAssemblyInfo.cs</Link>
- </Compile>
- <Compile Include="..\LibNMeCab\Settings.cs">
- <Link>Settings.cs</Link>
- </Compile>
- <Compile Include="Properties\AssemblyInfo.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="..\LibNMeCab\Properties\Settings.settings">
- <Link>Properties\Settings.settings</Link>
- <Generator>SettingsSingleFileGenerator</Generator>
- <LastGenOutput>Settings.Designer.cs</LastGenOutput>
- </None>
- <None Include="app.config" />
- </ItemGroup>
- <ItemGroup />
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <PropertyGroup>
- <PostBuildEvent>copy /y "$(TargetPath)" "$(SolutionDir)..\bin\MMF\"</PostBuildEvent>
- </PropertyGroup>
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
+++ /dev/null
-using System.Reflection;\r
-using System.Runtime.CompilerServices;\r
-using System.Runtime.InteropServices;\r
-\r
-// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。\r
-// アセンブリに関連付けられている情報を変更するには、\r
-// これらの属性値を変更してください。\r
-[assembly: AssemblyTitle("LibNMeCab")]\r
-[assembly: AssemblyDescription("")]\r
-//[assembly: AssemblyConfiguration("")]\r
-//[assembly: AssemblyCompany("")]\r
-//[assembly: AssemblyProduct("")]\r
-//[assembly: AssemblyCopyright("")]\r
-//[assembly: AssemblyTrademark("")]\r
-//[assembly: AssemblyCulture("")]\r
-\r
-// ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから \r
-// 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、\r
-// その型の ComVisible 属性を true に設定してください。\r
-[assembly: ComVisible(false)]\r
-\r
-// 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です\r
-[assembly: Guid("e16f6fba-3cf5-41fa-9002-5b0f91f87e05")]\r
-\r
-// アセンブリのバージョン情報は、以下の 4 つの値で構成されています:\r
-//\r
-// Major Version\r
-// Minor Version \r
-// Build Number\r
-// Revision\r
-//\r
-// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を \r
-// 既定値にすることができます:\r
-// [assembly: AssemblyVersion("1.0.*")]\r
-//[assembly: AssemblyVersion("1.0.0.0")]\r
-//[assembly: AssemblyFileVersion("1.0.0.0")]\r