cs-nlp-word-clustering 1.0.1

dotnet add package cs-nlp-word-clustering --version 1.0.1
NuGet\Install-Package cs-nlp-word-clustering -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="cs-nlp-word-clustering" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add cs-nlp-word-clustering --version 1.0.1
#r "nuget: cs-nlp-word-clustering, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install cs-nlp-word-clustering as a Cake Addin
#addin nuget:?package=cs-nlp-word-clustering&version=1.0.1

// Install cs-nlp-word-clustering as a Cake Tool
#tool nuget:?package=cs-nlp-word-clustering&version=1.0.1

cs-nlp-word-clustering

Implementation of word clustering such as Brown Clustering and One-Link Clustering in .NET

Install

Install-Package cs-nlp-word-clustering

Usage

The sample code show show how to use the BrownClustering to cluster words:

using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;

namespace WordClustering
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> word_sequence = new List<string>();
            Corpus corpus = new Corpus();
            using (StreamReader reader = new StreamReader("sample.txt"))
            {
                string[] words = reader.ReadToEnd().Split(new char[] { ' ', '?', ',', ':', '"', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string word in words)
                {
                    string w2 = word.Trim();
                    if (w2 == ".")
                    {
                        continue;
                    }
                    if (w2.EndsWith("."))
                    {
                        w2 = w2.Substring(0, w2.Length - 1);
                    }
                    if (!string.IsNullOrEmpty(w2) && word.Length > 1)
                    {
                        word_sequence.Add(w2);
                        corpus.Add(w2);
                    }
                }
            }

            int M = 70;
            Console.WriteLine("M: {0}", M);
            Console.WriteLine("Corpus Size: {0}", corpus.Count);
            Console.WriteLine("Document Size: {0}", word_sequence.Count);

            BrownClustering bc = new BrownClustering(M);
            bc.Cluster(corpus, word_sequence);

            Dictionary<string, List<string>> clusters = bc.GetClustersWithCodewordsOfLength(10);

            foreach (string codeword in clusters.Keys)
            {
                Console.WriteLine("In Cluster {0}", codeword);
                foreach (string word in clusters[codeword])
                {
                    Console.Write("{0}, ", word);
                }
                Console.WriteLine();
            }

            XmlDocument doc = new XmlDocument();
            XmlElement root = bc.ToXml(doc);
            doc.AppendChild(root);

            doc.Save("BrownClusteringResult.xml");

        
		}
    }
}
Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 1,101 4/30/2018

Word Clustering implemented in .NET 4.6.1