wasBayesSharp – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) |
2 | |||
3 | [![Build Status](https://travis-ci.org/afonsof/BayesSharp.svg)](https://travis-ci.org/afonsof/BayesSharp) |
||
4 | |||
5 | BayesSharp |
||
6 | ========== |
||
7 | |||
8 | Simple Naive Bayes text classifier |
||
9 | |||
10 | ## Basic Usage |
||
11 | |||
12 | #### 1. Setting Up |
||
13 | |||
14 | Create a Console Application and install BayesSharp using Nuget: |
||
15 | ``` |
||
16 | PM> Install-Package BayesSharp |
||
17 | ``` |
||
18 | |||
19 | #### 2. Instantiate the BayesSimpleTextClassifier class |
||
20 | ```c# |
||
21 | var c = new BayesSimpleTextClassifier(); |
||
22 | ``` |
||
23 | |||
24 | #### 3. Train the classifier with some data |
||
25 | ```c# |
||
26 | c.Train("spam", "Buy now some pills. You'll receive a free prize"); |
||
27 | c.Train("not spam", "Hello my friend, I miss you. I want to meet you soon."); |
||
28 | ``` |
||
29 | |||
30 | #### 4. Classify a new text |
||
31 | ```c# |
||
32 | var result = c.Classify("Hi my friend, I want to buy a gift for you"); |
||
33 | foreach(var item in result) |
||
34 | { |
||
35 | Console.WriteLine(item.Key + ": " + item.Value); |
||
36 | } |
||
37 | ``` |
||
38 | In this case, the output will be: |
||
39 | ``` |
||
40 | not spam :0,946523050631535 |
||
41 | spam: 0,748693773755381 |
||
42 | ``` |
||
43 | |||
44 | |||
45 | ## Contributing |
||
46 | |||
47 | Please use the issue tracker and pull requests. |
||
48 | |||
49 | ## License |
||
50 | Copyright (c) 2014 Afonso França |
||
51 | Licensed under the MIT license. |