Last active
June 29, 2021 07:47
-
-
Save conholdate-gists/f1699fc0dd9d47653ace12440f857337 to your computer and use it in GitHub Desktop.
Classify PDF Documents using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Classify PDF Documents using C# | |
1. C# API for Document Classification | |
2. Classify PDF Documents with IAB-2 Taxonomy using C# | |
3. Classify PDF with Documents Taxonomy using C# | |
4. PDF Document Classification from Document Stream using C# | |
5.Classify Password Protected PDF using C# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create classifier | |
var classifier = new Classifier(); | |
// classify password-protected document | |
var response = classifier.Classify("password-protected.pdf", @"C:\Files\", password: "password"); | |
// show classification information | |
Console.WriteLine(response.BestClassName, response.BestClassProbability); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create classifier | |
var classifier = new Classifier(); | |
// classify document with Document taxonomy | |
var response = classifier.Classify("sample.pdf", @"C:\Files\", 4, Taxonomy.Documents, PrecisionRecallBalance.Precision); | |
// show classification information | |
foreach (var r in response.BestResults) | |
{ | |
Console.WriteLine("ClassName: " + r.Name); | |
Console.WriteLine("ClassProbability: " + r.Probability); | |
Console.WriteLine("--------------------------------"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create classifier | |
var classifier = new Classifier(); | |
// classify document with IAB-2 | |
var response = classifier.Classify("sample.pdf", @"C:\Files\", 3, Taxonomy.Iab2); | |
// show classification information | |
foreach (var r in response.BestResults) | |
{ | |
Console.WriteLine("ClassName: " + r.Name); | |
Console.WriteLine("ClassProbability: " + r.Probability); | |
Console.WriteLine("--------------------------------"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var fs = File.OpenRead(Path.Combine(@"C:\Files\", "sample.pdf"))) | |
{ | |
// create classifier | |
var classifier = new Classifier(); | |
// classify document | |
var response = classifier.Classify(fs, "sample.pdf", 2, Taxonomy.Documents); | |
// show classification information | |
Console.WriteLine($"{"sample.pdf"}: {response.BestClassName}, {response.BestClassProbability}"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment