|
@@ -1,3 +1,5 @@
|
|
|
|
+using Azure;
|
|
|
|
+using HTEX.Test.Service;
|
|
using MathNet.Numerics;
|
|
using MathNet.Numerics;
|
|
using System.Configuration;
|
|
using System.Configuration;
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
@@ -39,89 +41,155 @@ namespace HTEX.Test
|
|
app.Run();
|
|
app.Run();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
public static string Test()
|
|
public static string Test()
|
|
{
|
|
{
|
|
- string originalString = "这 是 一 个 测 试。\n \r\t ";
|
|
|
|
- string stringWithoutSpaces = Regex.Replace(originalString, @"\s+", "");
|
|
|
|
- // 标准答案集合
|
|
|
|
- List<string> standardAnswers = new List<string> { "apple", "banana", "cherry" };
|
|
|
|
- // 学生作答集合
|
|
|
|
- List<string> studentAnswers = new List<string> { "bana1na", "orange", "grape", "111" };
|
|
|
|
-
|
|
|
|
- // 使用LINQ查询来判断是否有匹配的答案
|
|
|
|
- bool hasMatchingAnswer = standardAnswers.Intersect(studentAnswers).Any();
|
|
|
|
|
|
+ var a = new int[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27];
|
|
|
|
+ var b = new int[2192, 2379, 2070, 1813, 1662, 1421, 1134, 1043, 861, 763, 608, 563, 451, 358, 291, 252, 213, 170, 152, 133, 132, 95, 82, 71, 73, 63, 43];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // var per= GetPersent(array,3);
|
|
|
|
+ // Console.WriteLine(per);
|
|
|
|
+
|
|
|
|
+ //var data = MLService.GetNormalCluster(array.ToArray(),3,0.3);
|
|
|
|
+ // var group = array.GroupBy(x=>x).Select(x=>new { key = x.Key, list = x.ToList()}).OrderBy(x=>x.key);
|
|
|
|
+ // Console.WriteLine(group.Select(x => x.key).ToJsonString());
|
|
|
|
+ //Console.WriteLine(group.Select(x => x.list.Count()).ToJsonString());
|
|
|
|
+
|
|
|
|
+ //int count = 10;
|
|
|
|
+ //int score = 10;
|
|
|
|
+ //for (int i = 0; i < 10; i++)
|
|
|
|
+ //{
|
|
|
|
+ // int work = Random.Shared.Next(1, count);
|
|
|
|
+ // int right = Random.Shared.Next(1, work);
|
|
|
|
+ // double xIRS = (work+right);
|
|
|
|
+ // var exsIRS = 150/(1+Math.Exp(-(xIRS/2)))-75;
|
|
|
|
+ // Console.WriteLine($"{i}=》答题 {work}-----{right}: {exsIRS}");
|
|
|
|
+
|
|
|
|
+ // double xPIC = (work+right*3);
|
|
|
|
+ // var exsPIC = 40/(1+Math.Exp(-(xPIC/5)))-20;
|
|
|
|
+ // Console.WriteLine($"{i}=》挑人 {work}-----{right}: {exsPIC}");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // double xBUS = (work+right*3+(work-right));
|
|
|
|
+ // var exsBUZ = 80/(1+Math.Exp(-(xBUS/3)))-40;
|
|
|
|
+ // Console.WriteLine($"{i}=》抢权 {work}-----{right}: {exsBUZ}");
|
|
|
|
+
|
|
|
|
+ // int pscr = Random.Shared.Next(1, 10)*10;
|
|
|
|
+ // int gscr = Random.Shared.Next(1, 10)*10;
|
|
|
|
+ // double xSCR = (pscr + gscr );
|
|
|
|
+ // var exsSCR= 60/(1+Math.Exp(-(xSCR/8)))-30;
|
|
|
|
+ // Console.WriteLine($"{i}=》计分 {pscr}-----{gscr}: {exsSCR}");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // double xWRK = (work);
|
|
|
|
+ // var exsWRK = 150/(1+Math.Exp(-(xWRK)))-75;
|
|
|
|
+ // Console.WriteLine($"{i}=》作品 {work}-----{right}: {exsBUZ}");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // int vt = Random.Shared.Next(1, 3);
|
|
|
|
+ // int sc = Random.Shared.Next(1, 3);
|
|
|
|
+ // int cm = Random.Shared.Next(1, 3);
|
|
|
|
+ // int pt = Random.Shared.Next(1, 3);
|
|
|
|
+ // double xCMT = (vt + sc+cm*2+pt);
|
|
|
|
+ // var exsCMT = 100/(1+Math.Exp(-(xSCR/8)))-50;
|
|
|
|
+ // Console.WriteLine($"{i}=》评分 {vt}-----{sc}---{cm}---{pt}: {exsCMT}");
|
|
|
|
+
|
|
|
|
+ // int b = Random.Shared.Next(1, 100)/20;
|
|
|
|
+ // int m = Random.Shared.Next(1, 100)/20;
|
|
|
|
+ // int g = Random.Shared.Next(1, 10)/2;
|
|
|
|
+ // int t = Random.Shared.Next(1, 10)/2;
|
|
|
|
+ // double xXZ = (b + m+g+t);
|
|
|
|
+ // var exsXZ= 150/(1+Math.Exp(-(xSCR/8)))-75;
|
|
|
|
+ // Console.WriteLine($"{i}=》协作 {b}-----{m}---{g}---{t}: {exsXZ}");
|
|
|
|
+
|
|
|
|
+ // var xALL = xXZ+xCMT+xWRK+xSCR+xBUS+exsPIC+xIRS;
|
|
|
|
+ // var exsALL = 190/(1+Math.Exp(-(xALL/25)))-95;
|
|
|
|
+ // Console.WriteLine($"{i}=》所有: {exsALL}");
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //List<int> nums = new List<int>();
|
|
|
|
+ //for (int i = 0; i < 100; i++)
|
|
|
|
+ //{
|
|
|
|
+ // nums.Add(Random.Shared.Next(1,5));
|
|
|
|
+ //}
|
|
|
|
+ //for (int i = 0; i < 100; i++)
|
|
|
|
+ //{
|
|
|
|
+ // nums.Add(Random.Shared.Next(4, 8));
|
|
|
|
+ //}
|
|
|
|
+ //for (int i = 0; i < 100; i++)
|
|
|
|
+ //{
|
|
|
|
+ // nums.Add(Random.Shared.Next(5, 20));
|
|
|
|
+ //}
|
|
|
|
+ //for (int i = 0; i < 50; i++)
|
|
|
|
+ //{
|
|
|
|
+ // nums.Add(Random.Shared.Next(15, 36));
|
|
|
|
+ //}
|
|
|
|
+ //var per = GetPersent(nums, 11);
|
|
|
|
+ //bool[] anomalies = MarkAnomalies(nums);
|
|
|
|
+
|
|
|
|
+ //for (int i = 0; i < nums.Count; i++)
|
|
|
|
+ //{
|
|
|
|
+ // if (anomalies[i]) { Console.WriteLine($"Number{ i}: {nums[i]} is an anomaly."); }
|
|
|
|
+
|
|
|
|
+ //}
|
|
|
|
+ return "Hello World!";
|
|
|
|
+ }
|
|
|
|
|
|
- // 输出结果
|
|
|
|
- Console.WriteLine("学生答案中是否有符合标准答案的? " + (hasMatchingAnswer ? "是" : "否"));
|
|
|
|
|
|
+ static bool[] MarkAnomalies(List<int> array)
|
|
|
|
+ {
|
|
|
|
+ if (array.Count == 0) return new bool[0];
|
|
|
|
|
|
|
|
+ double average = array.Average();
|
|
|
|
+ double variance = array.Average(x => Math.Pow(x - average, 2));
|
|
|
|
+ double standardDeviation = Math.Sqrt(variance);
|
|
|
|
|
|
- string sentence1 = "学生答案中是否有符合标准答案的";
|
|
|
|
- string sentence2 = "学生答案中是否有标合标准答案的";
|
|
|
|
|
|
+ // 定义异常值的阈值,这里使用2倍标准差
|
|
|
|
+ double threshold =3* standardDeviation;
|
|
|
|
|
|
- double areSimilar = AreSentencesSimilar(sentence1, sentence2);
|
|
|
|
- Console.WriteLine($"Are the sentences similar? {areSimilar}");
|
|
|
|
|
|
+ bool[] anomalies = new bool[array.Count];
|
|
|
|
+ for (int i = 0; i < array.Count; i++)
|
|
|
|
+ {
|
|
|
|
+ double deviation = Math.Abs(array[i] - average);
|
|
|
|
+ anomalies[i] = deviation > threshold;
|
|
|
|
+ }
|
|
|
|
|
|
- List<string> a = new List<string>() { "a", "d" };
|
|
|
|
- List<string> b = new List<string>() { "b", "a", "c" };
|
|
|
|
- var v = (a.All(item => b.Contains(item)));
|
|
|
|
- string c = "[\r\n 1\r\n]";
|
|
|
|
- List<int> d = c.ToObject<List<int>>();
|
|
|
|
- return "Hello World!";
|
|
|
|
|
|
+ return anomalies;
|
|
}
|
|
}
|
|
- public static void calculate_text_similarity()
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 计算当前元素在集合中超过了多少百分比的值
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="nums"></param>
|
|
|
|
+ /// <param name="curr"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public static double GetPersent(IEnumerable<double> nums, int curr)
|
|
{
|
|
{
|
|
- string pythonExe = @"C:\Path\To\Python\python.exe"; // 修改为你的Python解释器路径
|
|
|
|
- string scriptPath = @"C:\Path\To\Your\Script\calculate_similarity.py"; // 修改为你的脚本路径
|
|
|
|
- string text1 = "今天天气真好";
|
|
|
|
- string text2 = "今天天气不错";
|
|
|
|
-
|
|
|
|
- ProcessStartInfo start = new ProcessStartInfo();
|
|
|
|
- start.FileName = pythonExe;
|
|
|
|
- start.Arguments = $"\"{scriptPath}\" \"{text1}\" \"{text2}\"";
|
|
|
|
- start.UseShellExecute = false;
|
|
|
|
- start.RedirectStandardOutput = true;
|
|
|
|
-
|
|
|
|
- using (Process process = Process.Start(start))
|
|
|
|
|
|
+ int count = 0;
|
|
|
|
+ foreach (var op in nums.OrderBy(x => x))
|
|
{
|
|
{
|
|
- using (StreamReader reader = process.StandardOutput)
|
|
|
|
|
|
+ if (op < curr)
|
|
{
|
|
{
|
|
- string result = reader.ReadToEnd();
|
|
|
|
- Console.Write(result);
|
|
|
|
|
|
+ count++;
|
|
}
|
|
}
|
|
- }
|
|
|
|
- }
|
|
|
|
- public static double CalculateSimilarity(string s1, string s2)
|
|
|
|
- {
|
|
|
|
- int n = s1.Length;
|
|
|
|
- int m = s2.Length;
|
|
|
|
- int[,] d = new int[n + 1, m + 1];
|
|
|
|
- for (int i = 0; i <= n; i++)
|
|
|
|
- {
|
|
|
|
- d[i, 0] = i;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (int j = 0; j <= m; j++)
|
|
|
|
- {
|
|
|
|
- d[0, j] = j;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (int i = 1; i <= n; i++)
|
|
|
|
- {
|
|
|
|
- for (int j = 1; j <= m; j++)
|
|
|
|
|
|
+ else if (op == curr)
|
|
|
|
+ {
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- int cost = (s1[i - 1] == s2[j - 1]) ? 0 : 1;
|
|
|
|
- d[i, j] = Math.Min(Math.Min(d[i - 1, j] + 1, d[i, j - 1] + 1), d[i - 1, j - 1] + cost);
|
|
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- return (1.0 - ((double)d[n, m] / Math.Max(s1.Length, s2.Length))) * 100;
|
|
|
|
|
|
+ return count *1.0/ nums.Count() * 100;
|
|
}
|
|
}
|
|
|
|
|
|
- public static double AreSentencesSimilar(string sentence1, string sentence2)
|
|
|
|
|
|
+
|
|
|
|
+ public class KeyCount
|
|
{
|
|
{
|
|
- // double threshold = 70; // 设置一个阈值,超过这个百分比则认为是相同的句子
|
|
|
|
- double similarity = CalculateSimilarity(sentence1, sentence2);
|
|
|
|
- return similarity ;
|
|
|
|
|
|
+ public int count { get; set;}
|
|
|
|
+ public int key { get; set;}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|