MyStemSharpness 1.1.0
dotnet add package MyStemSharpness --version 1.1.0
NuGet\Install-Package MyStemSharpness -Version 1.1.0
<PackageReference Include="MyStemSharpness" Version="1.1.0" />
<PackageVersion Include="MyStemSharpness" Version="1.1.0" />
<PackageReference Include="MyStemSharpness" />
paket add MyStemSharpness --version 1.1.0
#r "nuget: MyStemSharpness, 1.1.0"
#addin nuget:?package=MyStemSharpness&version=1.1.0
#tool nuget:?package=MyStemSharpness&version=1.1.0
⚙️ MyStemSharpness: High-Performance Library for MyStem Interaction in C#
Welcome to MyStemSharpness! This project is a carefully crafted .NET library in C# designed to provide efficient and convenient interaction with the powerful MyStem linguistic tool. We understand the importance of having a reliable and fast way to integrate MyStem's capabilities into your applications, and that's why we created this library.
⚠️ Warning: Multithreading Not Recommended!
The MyStem
and FastMyStem
classes are not designed for concurrent use from different threads within the same instance. If you need to perform analysis in a multithreaded environment, it is strongly recommended to create separate instances of the MyStem
or FastMyStem
classes for each thread.
🚀 Getting Started
If you're ready to dive into the world of linguistic analysis with MyStemSharpness, here are the first steps:
Installation: Currently, the library is under development and can be installed directly from the source code. Once published on NuGet, you will be able to add it to your Visual Studio Code or other .NET project using the following command in the NuGet Package Manager console:
dotnet add package MyStemSharpness
Adding Namespace: In the files where you plan to use MyStemSharpness, add the following line at the beginning:
using MyStem;
MyStem Dependency: The library requires the
mystem.exe
executable to be installed on the target machine. Ensure it is accessible at the specified path.
🛠️ Usage Examples
To help you quickly appreciate the capabilities of MyStemSharpness, we have prepared several usage examples for different scenarios.
💡 Single-Threaded Analysis (MyStem)
For tasks where a high degree of parallelism is not required or processing is performed sequentially, you can use the MyStem
class.
using MyStem;
using System;
using System.IO;
public class SingleThreadedExample
{
public static void Main(string[] args)
{
// Specify the path to the MyStem executable if it's different from "mystem.exe"
MyStem.PathToMyStem = "path/to/mystem.exe";
// Create an instance of the class
using var myStem = new MyStem();
myStem.Initialize(); // Initialize the MyStem process
string textToAnalyze = "Это простой пример текста для анализа.";
try
{
string result = myStem.Analysis(textToAnalyze);
Console.WriteLine($"Analysis Result: {result}");
}
catch (FileNotFoundException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
catch (FormatException ex)
{
Console.WriteLine($"Error during analysis: {ex.Message}");
}
}
}
⚡ Fast Analysis (FastMyStem)
For applications where high performance is important, use the FastMyStem
class.
using MyStem;
using System;
using System.IO;
public class FastMyStemExample
{
public static void Main(string[] args)
{
// Specify the path to the MyStem executable if it's different from "mystem.exe"
FastMyStem.PathToMyStem = "path/to/mystem.exe";
// Create an instance of the class
using var myStem = new FastMyStem();
string textToAnalyze = "This text will be processed using FastMyStem.";
try
{
string result = myStem.MultiAnalysis(textToAnalyze);
Console.WriteLine($"Fast Analysis Result: {result}");
}
catch (FileNotFoundException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
catch (FormatException ex)
{
Console.WriteLine($"Error during analysis: {ex.Message}");
}
}
}
⚙️ Configuring MyStem Parameters
The library provides the MyStemOptions
class for flexible configuration of MyStem's launch parameters.
using MyStem;
using System;
using System.IO;
public class OptionsExample
{
public static void Main(string[] args)
{
// Create an object with the desired options
var options = new MyStemOptions
{
LineByLine = true,
PrintOnlyLemmasAndGrammemes = true,
Encoding = "utf-8"
};
// Specify the path to the MyStem executable
MyStem.PathToMyStem = "path/to/mystem.exe";
// Create an instance of the class, passing the options
using var myStem = new MyStem(options);
myStem.Initialize(); // Initialize the MyStem process
string textToAnalyze = "Пример текста с настройками.";
try
{
string result = myStem.Analysis(textToAnalyze);
Console.WriteLine($"Analysis Result with Options: {result}");
}
catch (FileNotFoundException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
catch (FormatException ex)
{
Console.WriteLine($"Error during analysis: {ex.Message}");
}
}
}
⚠️ Potential Development Issues
During the development and use of the MyStemSharpness library, some difficulties may arise:
- Encoding: Incorrect encoding settings can lead to incorrect text analysis. UTF-8 is used by default, but you can configure other encodings via
MyStemOptions
if needed. - MyStem Error Handling: While the library tries to handle exceptions, errors originating directly from the MyStem process might require additional diagnostics.
- System Resources: Running the external MyStem process can consume system resources. With intensive use in a multi-threaded environment, monitor CPU and memory usage.
⚡ High-Performance Guarantee
Despite potential difficulties, MyStemSharpness is designed with a focus on high performance:
- Efficient Process Management: The library reuses MyStem process instances, minimizing the overhead of starting new processes for each request.
- Asynchronous Reading (Class
FastMyStem
): TheFastMyStem
class uses asynchronous reading of MyStem's output, which prevents blocking the calling thread and increases overall throughput. Please note: the same instance ofFastMyStem
is not intended for safe use in different threads simultaneously. For multithreaded processing, it is recommended to create separate instances of the class for each thread. - Optimized Buffers: Buffers are used for reading output data, and their size is dynamically estimated based on the input text size, reducing the number of memory allocation operations.
🙏 Acknowledgments and Contributions
We hope that MyStemSharpness will become a valuable tool in your arsenal. We welcome your feedback, suggestions, and contributions to the project's development. Stay tuned for updates and new features!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net6.0
- 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.