/// <summary> /// Izvršava test i vraća rezultat u obliku string reporta /// </summary> /// <param name="model"></param> /// <param name="testWord"></param> /// <param name="operation"></param> /// <returns></returns> public static string testAndReport(this basicLanguage model, string testWord, basicLanguageCheck operation) { if (model == null) { return("Selected model is null!" + Environment.NewLine); } string output = "Language model: " + model.iso2Code + Environment.NewLine; if (string.IsNullOrEmpty(testWord)) { output += "[error] Test word is empty" + Environment.NewLine; return(output); } if (!model.checkHuspell(true)) { return(null); } object res = null; if (operation == basicLanguageCheck.fullAnalysis) { basicLanguageCheck[] ops = Enum.GetValues(typeof(basicLanguageCheck)) as basicLanguageCheck[]; foreach (basicLanguageCheck op in ops) { if (op != operation) { output += testAndReport(model, testWord, op) + Environment.NewLine + Environment.NewLine; } } } else { res = model.test(testWord, operation); } output += "Test operation: " + operation.ToString() + " >> result: " + res.ToString() + Environment.NewLine; List <string> ls = res as List <string>; if (ls != null) { int c = 0; foreach (string it in ls) { c++; output += "[" + c + "] " + it + Environment.NewLine; } } return(output + Environment.NewLine); }
/// <summary> /// Univerzalni test poziv /// </summary> /// <param name="model"></param> /// <param name="testWord"></param> /// <param name="operation"></param> /// <returns></returns> public static object test(this basicLanguage model, string testWord, basicLanguageCheck operation) { if (!model.checkHuspell()) { return(null); } object output = null; if (string.IsNullOrEmpty(testWord)) { //model.note(devNoteType.nlp, // "Test word is null - operation: " + operation.ToString() + " language:[" + model.iso2Code + // "] ", "basicLanguageTools.test()"); //logSystem.log("Test word is empty", logType.Warning); return(null); } try { switch (operation) { case basicLanguageCheck.fullAnalysis: List <object> outlist = new List <object>(); outlist.Add(model.hunspellEngine.Spell(testWord)); outlist.Add(model.hunspellEngine.Analyze(testWord)); outlist.Add(model.hunspellEngine.Stem(testWord)); outlist.Add(model.hunspellEngine.Suggest(testWord)); return(outlist); break; case basicLanguageCheck.spellCheck: return(model.hunspellEngine.Spell(testWord)); break; case basicLanguageCheck.analyze: return(model.hunspellEngine.Analyze(testWord)); break; case basicLanguageCheck.getStems: return(model.hunspellEngine.Stem(testWord)); break; case basicLanguageCheck.getVariations: return(model.hunspellEngine.Suggest(testWord)); break; default: return("Not supported operation"); break; } } catch (Exception ex) { // logSystem.log(ex.Message, logType.Warning); throw; } return(output); }