ML implemented
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
namespace Application.Endpoints.SicknessPrediction;
|
||||
|
||||
public class SicknessPredictionHandler
|
||||
{
|
||||
public async Task<BaseResponse> GetPrediction(SicknessPredictionDto dto)
|
||||
{
|
||||
var validation = new SicknessPredictionValidator();
|
||||
var validationResult = await validation.ValidateAsync(dto);
|
||||
|
||||
if (!validationResult.IsValid)
|
||||
{
|
||||
var firstError = validationResult.Errors.FirstOrDefault();
|
||||
var errorCode = int.TryParse(firstError.ErrorCode, out var code) ? code : -1;
|
||||
var errorMessage = firstError.ErrorMessage;
|
||||
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = errorCode,
|
||||
Message = errorMessage,
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
var currentDirectory = Directory.GetCurrentDirectory(); // gets the current working directory
|
||||
var applicationDirectory = Path.Combine(Directory.GetParent(currentDirectory)?.FullName, "Application");
|
||||
|
||||
var scriptPath = Path.Combine(applicationDirectory, "Endpoints","SicknessPrediction", "SicknessPredictionScript.py");
|
||||
var scriptRunner = new PythonScriptRunner();
|
||||
var result = await scriptRunner.RunPythonScript(scriptPath, dto.Text);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user