From 45b2eea3d2a6b62250689c909a72bf658fb3bedf Mon Sep 17 00:00:00 2001 From: ovo Date: Fri, 27 Dec 2024 16:07:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=8A=A0=E5=85=A5docker-java):=20?= =?UTF-8?q?=E5=8A=A0=E5=85=A5docker-java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/com/guwan/backend/Demo.java | 56 ++++++++- .../com/guwan/backend/ScoreProcessor.java | 117 ++++++++++++++++++ .../java/com/guwan/backend/TxtFilter.java | 60 +++++++++ 3 files changed, 232 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/guwan/backend/ScoreProcessor.java create mode 100644 src/test/java/com/guwan/backend/TxtFilter.java diff --git a/src/test/java/com/guwan/backend/Demo.java b/src/test/java/com/guwan/backend/Demo.java index 19d0159..a5548e9 100644 --- a/src/test/java/com/guwan/backend/Demo.java +++ b/src/test/java/com/guwan/backend/Demo.java @@ -1,10 +1,14 @@ package com.guwan.backend; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; +import java.util.List; public class Demo { public static void main(String[] args) { @@ -38,7 +42,13 @@ public class Demo { System.out.println("v = " + v);*/ - double[] doubles = {0.00813358,-0.0717444,0.0427521,-0.09976,0.0173086,0.0541312,0.0306966,0.00394333,-0.0805283,0.0212356,0.024662,-0.0316266,-0.0549666,-0.0254094,-0.0177571,0.10131,0.020701,0.0441507,0.0209388,-0.0609514,-0.00752474,0.064366,0.00522364,0.0639835,-0.0069507,-0.040016,0.000307553,0.0181802,-0.0515554,0.00562997,0.0377858,-0.0345202,0.0176173,0.0706512,0.0191343,0.0219548,-0.0193649,-0.0554424,-0.0403851,-0.031703,0.041354,-0.00468077,-0.0417664,0.00813455,0.0400847,-0.0329072,-0.0243407,-0.0212622,0.0476396,0.0032689,-0.0529252,-0.0255618,0.0226095,0.0289798,0.0154113,0.0506448,-0.0310787,0.0230591,-0.0231555,0.0627712,0.0651164,-0.099749,0.0608207,0.0110909,0.0393236,0.0641128,-0.0343113,0.0632619,-0.013106,-0.0066061,-0.0342352,-0.0585004,-0.0184951,-0.0111713,-0.0491843,-0.0419517,0.0886513,-0.0304402,0.0217467,-0.00603824,0.0490426,0.059213,0.0994015,0.0988817,-0.055298,0.0493214,-0.0207087,0.0374041,0.00929751,0.0599644,0.0102726,-0.0697873,0.0332286,-0.00338293,-0.046579,0.0220471,0.0664113,0.0297177,-0.037593,0.036519,0.0189942,-0.11936,-0.116896,0.0312246,0.00496536,-0.0845305,-0.0335346,0.0265305,0.0162978,-0.040161,-0.00733538,0.0347841,-0.0407326,-0.0661045,0.0699116,-0.0203981,-0.0328153,-0.0171557,-0.0182742,0.0217934,0.059479,0.00676392,0.056972,0.0186473,0.0660729,0.0540374,-0.0215442,-0.0467004,-0.0413617,0.035326,-0.00266819,0.0497006,-0.0131862,-0.0294214,-0.034219,0.0655005,0.0773711,-0.00104823,0.0259,0.0571103,0.00544036,-0.0151371,-0.0102787,-0.0318289,0.0401575,0.0224744,0.0532478,0.0111713,0.0328278,-0.00557172,-0.0448797,0.0153216,-0.00870144,0.0102774,-0.0268038,-0.0253763,-0.0293621,0.0675536,0.00694246,0.0415049,0.049479,0.0552152,0.0740348,0.00371429,-0.0278621,0.0279626,-0.00316676,-0.0216128,-0.0180461,0.0284524,0.0435371,-0.0966685,-0.0685613,-0.0737684,-0.0878846,0.0559887,0.0151115,0.0556193,-0.0268792,0.0729819,-0.0174645,0.00889404,-0.0532627,0.0306943,0.0248191,0.0311554,0.0507284,-0.0581995,-0.015319,-0.00993474,0.0343203,-0.00293242,-0.0679642,-0.0317756,0.0795038,-0.0228966,0.0165235,0.0192136,-0.0740935,-0.0176364,0.0105555,-0.0102294,-0.0527158,-0.0106637,-0.00498221,-0.0278876,0.0525176,0.0308213,-0.0131481,0.0282111,0.059723,-0.0175435,0.00480513,0.118406,-0.00851074,0.0129108,-0.106426,0.0821999,-0.0366637,-0.0424306,-0.00361276,0.0169177,0.0715828,-0.00977725,-0.045531,-0.0244507,0.0239735,-0.026374,-0.0783486,-0.0343596,-0.0114915,-0.043448,-0.0314955,0.0233727,-0.0665008,-0.0514264,-0.0137363,0.0248842,0.0331309,0.10228,-0.0369261,-0.024313,0.0730804,0.0256739,-0.0418357,0.0114184,0.00298331,0.0378631,-0.00659492,-0.0360407,-0.0572441,0.02682,0.120875,0.0165255,0.0258486,0.0673768,0.0416781,-0.0479553,0.0344875,-0.0305185,-0.00432772,0.00405022,-0.0336527,-0.0605726,0.00420731,0.040132,0.0334531,-0.00604246,-0.0572285,-0.02673,0.00990644,-0.0737214,-0.00106789,-0.0177951,-0.0111799,-0.0189305,0.0576103,-0.011856,0.0170181,0.0135687,-0.00121104,0.00512214,-0.0331864,0.0563632,-0.00821232,0.0415726,0.0357308,-0.0108296,-0.0133349,0.0081604,0.0624835,0.0221947,0.00171568,-0.0558194,-0.0138043,0.0183192,-0.076997,0.011497,0.0136875,0.0801916,0.0159631,-0.0965699,-0.0109675,-0.0534059,-0.0339581,-0.064359,-0.0583422,0.0476007,0.0491197,-0.00335155,0.00699328,-0.00400689,-0.132372,-0.0583276,-0.00137148,-0.0300449,0.00351384,-0.111098,-0.0393222,0.0193242,-0.0708553,0.025889,0.0250999,-0.032441,0.0520303,-0.0476663,0.0826722,0.0493515,0.0482016,-0.0146799,0.0557716,-0.0279748,-0.0487825,-0.00757696,0.016103,0.0182013,0.041443,0.0145562,0.0128525,-0.0201599,-0.0239923,0.0782862,0.0386663,0.0509694,0.00126989,0.0802744,-0.0711916,0.0419414,-0.0500852,-0.00560524,0.0400302,0.0896108,-0.0342832,-0.0252033,-0.0120862,-0.0299239,-0.0153841,0.023048,-0.0375552,0.0760825,-0.0235246,0.0255638,-0.0109557,-0.0666985,-0.10058,0.00668788,0.0678599,0.0255118,-0.0196562,-0.0419511,0.0197536,0.0404723,-0.00663104,0.0516145,-0.028388,-0.0420597,0.0593952,0.00260946,0.041337,-0.022394,0.00108294,0.0238998,-0.0776414,0.0604176,0.024695,-0.0175343,0.0512133,-0.00976876,0.0108986,0.0156592,0.0146911,0.00103359,0.00483782,-0.00453627,-0.0126626,-0.0583435,0.0300467,-0.00358963,-0.015861,0.0254458,-0.042379,-0.0396319,-0.0471911,0.0563009,-0.0189772,-0.0169601,0.0566614,-0.0148013,-0.0207863,-0.0592948,0.00818789,-0.0400569,0.0119037,0.0697768,-0.0554179,0.0318442,0.095889,0.0414195,0.00793982,0.0349136,-0.0059633,-0.0970189,-0.00796388,-0.0374666,-0.0432851,0.0118731,0.144213,0.0052473,0.0681348,0.0267628,-0.0462023,0.0193755,-0.035904,0.0935881,0.0197338,0.0249323,-0.0240679,-0.0103057,-0.0540255,-0.0249126,0.0220931,-0.0999261,-0.0515874,-0.0125428,-0.0218904,0.00512178,-0.0331139,0.0579583,-0.0546361,-0.0497459,0.00122892,-0.00242525,-0.0354115,-0.00263322,0.023803,-0.022895,-0.0222722,-0.0336936,0.106722,0.0139875,0.0117573,0.00639695,-0.00178353,-0.0143335,-0.000502704,0.000453445,-0.0517741,-0.0569606,0.0344537,-0.0169397,-0.0194627,0.00401172,-0.0776682,0.0106159,0.0448228,-0.0581184,0.0474312,-0.0105137,-0.0188604,0.0658761,-0.0379375,0.0247569,0.0101027,0.0702604,0.0265442,0.0748215,0.0269084,0.0662915,-0.0269496,0.018373,-0.0454977,-0.0739088,0.00836531,0.00724072,-0.0370967,0.00322413,0.0311968,0.00559982,0.00924689,-0.0355415,0.0532134,-0.0193161,-0.0372191,-0.0177027,-0.000354273,0.00304729,-0.0220334,-0.0721528,-0.0645963,-0.0104013,-0.03248,0.0872043}; + + String filePath = "D:\\00_桌面\\1.txt"; + + double[] doubles = readFileToDoubleArray(filePath); + + + // double[] doubles = {-0.0740287,-0.0637177,0.0944422,-0.0186904,-0.0244772,-0.0197649,0.144102,-0.00837358,-0.0605576,0.0431705,-0.0368744,0.054256,0.01712,-0.0222409,-0.113621,0.0555789,0.00729382,0.0810636,-0.0353784,-0.0744284,0.00652374,0.00970493,-0.000814297,0.0399442,-0.0146078,-0.0105109,0.0274556,0.0128535,-0.0170786,0.0206462,0.0140499,0.0127464,-0.0178677,0.0839654,-0.0816912,-0.00347137,-0.0190675,-0.123918,-0.03485,0.0493903,-0.0201296,0.0417684,0.043084,0.0356119,-0.00833263,0.0111646,-0.0592772,0.0263525,-0.0190948,0.0326857,-0.000431495,0.0185265,-0.0116345,-0.0559995,-0.0476906,0.0643263,0.0405468,0.00721956,-0.0109348,-0.0678697,0.0527629,0.0499273,0.00545235,0.0774691,-0.0566223,0.0730349,0.0261401,-0.0295663,-0.0392466,-0.0295928,-0.0454372,-0.052813,-0.047686,-0.0197103,-0.00208006,-0.00681011,-0.000124741,0.00320523,0.0999344,-0.0962769,-0.033607,0.0386489,-0.03253,0.0632501,0.00375405,0.00107361,-0.0331475,-0.027696,0.0437495,0.062174,0.0305235,-0.0327681,-0.00150118,-0.0439075,-0.0580992,-0.0335615,0.0118914,-0.0267377,0.0412954,0.0403707,0.00998491,0.0299647,-0.0105119,0.00575388,0.0511927,-0.0699991,0.0493362,-0.00769025,0.0483461,-0.00306804,0.0114459,-0.00275108,0.0189502,-0.0609815,0.0205354,0.0443575,-0.0215924,0.00199942,-0.0212312,0.00834188,-0.00429202,-0.0427853,0.0341914,0.0111295,0.0501493,0.0309206,0.0108863,-0.0640758,-0.0867864,-0.0606901,0.00430255,-0.0346624,0.0227585,-0.0845103,-0.0887615,0.018807,-0.0386612,0.0427513,0.011042,0.00331091,0.0691908,0.00719541,0.00751851,-0.0099789,0.0147282,0.0228223,0.00214297,-0.00927096,-0.0109164,-0.00464938,0.00739155,-0.0428943,-0.0383528,0.0245316,-0.0257388,-0.0537963,0.0891818,0.054967,-0.0287611,0.0383871,0.0289396,0.0544246,-0.0231423,0.0584708,-0.033964,0.09216,0.00169525,0.0118831,0.0333599,0.0220797,0.0390131,-0.0543666,-0.0447782,-0.0237474,-0.0240657,0.0284623,-0.0119641,0.0143863,-0.0716646,0.0690669,0.0160611,-0.0776545,-0.00499118,-0.00955065,-0.0743043,0.00899923,-0.0240596,0.00945836,0.0234366,0.0266028,-0.0830384,-0.0355449,0.0160775,-0.067092,-0.0177727,0.0261098,0.0435525,-0.0224834,-0.0188278,0.0747525,0.0338263,0.0523852,-0.017214,-0.0505042,0.125675,0.0559449,-0.00752209,-0.0285899,-0.00025598,-0.0602169,0.00720326,-0.0437507,-0.0567395,0.0152849,-0.0200612,-0.0615939,-0.0524682,0.0307808,0.0231439,-0.0252274,-0.0122398,0.0158367,0.0442698,-0.00981589,-0.0752206,-0.0104204,-0.0143505,-0.0935699,-0.00908855,-0.0941793,-0.0185951,-0.0399137,0.0335459,-0.0245082,-0.0118512,-0.0619392,-0.0387612,-0.0457014,0.0130861,0.00706539,-0.000875193,-0.00788267,0.0066103,-0.00888384,-0.0711766,0.0756452,0.0182097,0.0440055,0.0295221,-0.0607578,-0.00269516,-0.160971,0.0402193,0.0218543,0.0135813,0.0389046,-0.0367599,-0.0342865,-0.024962,0.00129079,-0.0266265,-0.0624669,0.0556822,-0.0180575,-0.13543,0.0525405,0.040761,-0.0295952,0.0329132,-0.0709344,-0.0439236,-0.0667479,0.102541,-0.018027,0.0181308,0.0366018,0.0340139,0.0684204,0.0605241,-0.0302509,0.0451231,0.00189036,-0.0167314,- 0.101451,0.00736781,-0.0848834,-0.024152,0.117477,0.00717903,0.0244913,0.0117018,-0.00278936,0.00526691,0.01168,-0.0382042,-0.0120691,-0.0943397,0.0065184,-0.0952804,-0.0145431,0.00880615,-0.0365711,-0.0688171,0.0275255,-0.0226922,-0.0492349,-0.011049,-0.0121977,0.0519495,0.0189065,0.0178785,-0.0444225,-0.0087021,-0.032812,-0.0208616,0.0385055,0.00815373,-0.0132905,0.0543238,-0.0500573,0.00329751,-0.00461195,-0.034731,-0.0417068,0.0480248,-0.0481742,0.059069,-0.0111483,0.0261829,0.0162477,-0.00364784,0.0680943,-0.0808296,0.0208607,0.0395282,0.0133873,0.032232,0.0468654,-0.0199968,-0.0585562,-0.0476538,0.0828568,0.0209821,-0.0103604,-0.0361541,-0.0486414,-0.053165,-0.00895089,-0.00155764,0.0174003,-0.0856857,0.0445384,-0.0440823,-0.0594024,-0.0603975,-0.00123617,-0.0114459,0.0247099,-0.0305196,-0.0029419,-0.0374037,0.0310554,-0.0435151,-0.0480049,0.00772029,-0.0303852,-0.0470322,-0.0701254,0.0212398,-0.00974331,0.103958,0.0408849,-0.00118392,-0.0306719,0.0358709,0.042319,0.0446014,-0.0311961,0.0780172,0.0175182,-0.014268,-0.0443475,-0.0535637,-0.0279585,-0.0513043,0.0285866,-0.0201047,-0.0450271,0.0550524,0.0164524,-0.0153946,-0.0204496,0.0177429,-0.0753144,-0.0934228,-0.0489658,-0.00349609,-0.00126021,-0.0167969,0.035919,-0.0771248,-0.0234764,0.000137633,-0.0263282,-0.0656772,0.0230899,0.00467026,-0.0317044,-0.0674252,-0.0243306,0.052915,0.0380282,0.0205004,0.0858908,-0.00943692,-0.0563388,0.0210702,0.0461318,-0.0243721,0.0154728,-0.00189041,-0.024599,-0.062951,0.0304872,-0.0802064,0.0791014,0.0516576,0.0302207,0.000807211,0.000760314,-0.0335269,0.0370095,-0.00878161,-0.0188183,-0.0197322,-0.020432,-0.00644914,0.0050795,-0.0203916,-0.0403374,-0.00935411,-0.00793978,-0.0306334,-0.0113693,-0.0243014,0.0443873,0.0127655,0.0312347,-0.0146438,-0.0242781,-0.0353635,-0.000367259,0.0184114,0.0391262,-0.0479372,0.011484,-0.049179,-0.0600858,0.118867,0.0525475,0.00669193,-0.0444946,0.0493893,0.0306757,0.0036988,0.0260675,0.0118989,-0.00748049,-0.0339875,-0.0201925,-0.067779,0.0414398,0.0701444,0.0397202,0.10801,-0.0433297,-0.0239343,-0.0420598,-0.0139324,-0.0564921,0.0503346,0.0809587,0.0158232,-0.0116017,-0.0104577,-0.0135858,-0.0088444,-0.0582514,-0.0658726,0.0287392,-0.0727066,-0.00988229,-0.0461841,-0.0631158,-0.0013518,0.00285035,0.0482472,-0.0179195,0.00677553,-0.0322023,-0.0389652,-0.0156639,-0.0443295,-0.0150816,0.0147936,0.00297346,-0.0121302,0.0649004,0.0349235,-0.0304057,-0.00411399,0.0641686,-0.0254396,0.0386145,-0.0638637,-0.0601737,0.00857781,0.100203,-0.0241054,0.00384146,0.0685298,-0.0185564,-0.0139558,-0.00819243,-0.0778413,0.048672,-0.0533105,0.021715,-0.0362242,-0.0277885,0.00850214,0.0435866,-0.0159403,-0.0277716,-0.0319829,-0.0421879,0.0470328,0.0623997,-0.0620262,-0.0634304,-0.0519113,0.0491632,-0.00137516,0.000923441,0.0462714,0.051987,0.0696814,0.0390612,-0.0208087,-0.0580833,-0.0460739,-0.0463694,0.0716125,-0.0139578,-0.00107367,0.00203204,0.0228416,0.0210471,0.0071459,0.00979208,0.00781117,-0.0524235,0.051669,-0.0442722,-0.07566,0.061546,0.0362219,-0.00404184,-0.00309274,0.0267969,0.000459871,-0.00349756,0.0900061,-0.0730837,-0.113329,-0.0485057,-0.0195904,0.0605352,-0.0484708,0.0567292,-0.0209168,-0.0320092,0.0479503,-3.36401e-05,0.0671855,0.104952,0.00239661,0.027286,0.0492629,-0.0158145,-0.0881498,-0.0739685,0.0153191,-0.0199458,-0.0508765,0.0838389,-0.00305567,0.0169686,0.0946554,-0.0407737,-0.00430473,0.0635631,-0.0738098,0.0301512,0.0218131,-0.0937515,-0.0109078,0.0252908,-0.0858197,-0.00434976,0.0310777,0.0248984,-0.0512043,-0.0169824,-0.0187164,-0.0293491,0.0307621,0.0140667,0.0177293,0.0400326,0.0245607,-0.0828408,-0.0411284,0.0254475,0.0515275,-0.0873955,0.0031015,0.0363077,-0.0409984,-0.0338817,-0.0453241,0.00640786,-0.0205521,0.0019252,-0.0108555,-0.0128334,-0.0160258,-0.0466504,0.0312735,-0.0172495,-0.0694907,0.0337497,-0.00644589,0.0727794,0.0506976,-0.0497929,0.0781684,0.0702919,-0.0493273,-0.00696438,-0.0268441,0.00298872,-0.0184491,-0.0475623,-0.00238431,-0.00782648,0.0587275,-0.0430772,-0.0134244,-0.048755,0.00215971,0.0870315,0.0270079,0.079719,0.0355115,0.0305147,-0.0574763,-0.0527641,0.0722514,0.0277584,0.0134914,-0.0368518,0.0249281,0.0420037,0.0158843,-0.0420702,0.00715308,-0.044794,-0.0318641,0.00856695,-0.0574641,0.0107886,-0.047468,-0.0318431,0.0310206,0.0719075,-0.0284972,-0.0388292,0.0571699,0.0126766,-0.00659434,-0.0037426,0.00259973,0.0720558,0.020477,-0.0624792,-0.0324575,0.0564663,0.0297118,0.0134022,0.0853054,-0.0272868,0.0113952,0.0092119,-0.079327,-0.036239,0.0330449,-0.0676028,0.0451006,-0.0278012,0.00990602,-0.00444191,0.0416564,-0.0395604,-0.0404825,-0.0297834,0.00891985,0.00392211,-0.00558514,0.0403608,-0.0227121,-0.0290898,-0.0248196,0.0469029,-0.0250082,0.0510658,0.0362856,-0.0176549,-0.0680756,-0.0518433,0.061565,-0.00146044,0.00242568,-0.0249091,-0.0774799,0.0622868,0.00943911,0.101047,0.0853694,-0.00760762,-0.011394,0.0624434,0.052224,0.0639171,0.061451,-0.0274929,-0.0710621,0.00792462,-0.000488645,0.0292382,-0.0249453,-0.00953469,0.0767752,0.054426,-0.0580246,0.0635299,0.0388395,0.0427981,0.0453802,0.0101281,0.0302506,0.0222551,0.0639419,0.021454,-0.00220969,0.0174016,-0.038788,0.0325108,0.03482,-0.0444189,0.00146073,0.0212143,0.0466131,0.0405334,-0.0256796,-0.088073,0.0230325,-0.0525862,-0.0790478,0.0156055,0.016773,0.0413111,-0.0829236,0.00192125,0.0100544,0.024921,-0.0569135,0.00698634,0.064482,0.0464288,-0.00204033,-0.0703521,0.0282477,0.0142044,-0.0369096,-0.0479724,0.018841,0.00361868,-0.0179246,0.0177665,-0.0304072,0.0558303,-0.0311429,0.00988206,0.0251081,-0.00784071,0.0131734,-0.0636308,0.0187265,0.0170467,0.0187696,0.0797149,-0.0355361,0.0865736,-0.0136471,-0.00209712,-0.0525366,0.018659,0.033528,-0.0550165,0.015248,0.020728,-0.0866455,0.0108468,0.0306191,-0.00221258,0.0144426,0.0708712,0.0133719,0.00340734,0.0126272,0.0310334,-0.0407962,0.011345,-0.0196781,0.0417137,-0.0518806,-0.0139852,0.00687544,-0.0462662,0.0790974,0.0302464,0.0323652,0.054244,-0.0181655,0.0102835,-0.0942258,0.00873275,0.0471475,0.000366873,0.0284248,-0.0131211,0.00544102,0.0297489,0.0178382,0.0364277,-0.00496274,0.0470249,0.0216141,-0.00146819,-0.0113023,0.0387215,0.0103412,0.0506569,-0.0873389,0.013113,0.0738708,-0.0174334,-0.00739151,-0.0191604,0.0501107,-0.0669245,0.0514182,-0.0329623,0.00391888,-0.0997835,-0.0163992,-0.0206549,-0.0436608,-0.0206139,0.0128378,-0.00625268,0.0568689,0.0149409,-0.000370883,0.0658009,0.0189694,0.00193447,-0.00969304,-0.0432521,0.04306,-0.00719686,-0.10265,-0.0114459,0.0266584,0.0204908,0.0080129,0.00214976,-0.0483741,0.0282553,-0.0679196,0.0783728,0.0754499,-0.00139188,0.0389506,0.00711148,0.112846,0.00544148,0.00948495,0.0581645,-0.0251901,0.037831,-0.0406402,-0.00232724,0.093437,0.0518216,0.0656957,0.0196582,0.0183917,-0.0900192,0.0644038,0.0313428,0.0747573,-0.0700415,0.00214599,0.105271,0.0431045,0.102228,-0.0454938,-0.0539273,0.0397524,-0.00941618,0.0714819,0.0148545,-0.0703038,0.0269324,-0.0106744,0.0180094,-0.0439474,0.0216032,0.0423625,0.0662182,0.000423646,0.0156219,0.000812148,-0.00513984,0.0182412,0.0527621,0.0150308,-0.0606007,0.0683195,0.0174269,0.0070262,0.043291,-0.0620077,-0.0746348,0.00600855,0.061064,0.00516871,-0.0325368,0.031642,-0.0307235,-0.0485787,0.0333377,-0.0221634,0.0281362,0.00458627,-0.0652254,-0.0450353,0.00446873,-0.0499703,0.0579811,-0.0260338,0.0589342,-0.0063536,-0.00407467,-0.00504872,0.0668654,-0.0710919,0.0112762,-0.0712705,-0.0357393,0.00204814,-0.00687733,0.0726379,0.00525034,0.0567115,0.0430375,-0.0535412,0.0115156,0.0226128,-0.0395195,-0.0820172,0.000861403,-0.0326414,-0.0241076,-0.0314644,0.0190739,-0.075019,-0.00818995,-0.0250545,-0.0465021,0.0180276,-0.00885727,0.0457064,-0.052608,-0.0714925,-0.00631446,-0.0622597,0.0215259,0.0387637,0.0105939,0.067722,0.0722417,0.00357204,-0.0660515,0.0131136,-0.00248913,0.0196209,-0.00963444,0.0487294,-0.00974963,-0.0825616,-0.016534}; // double[] doubles = {}; // double数组转float数组 @@ -58,6 +68,50 @@ public class Demo { System.out.println("feature = " + feature); } + + + // 从文件读取并转换为 double[] 数组 + public static double[] readFileToDoubleArray(String filePath) { + List doubleList = new ArrayList<>(); // 用于存储读取到的 double 数值 + + try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { + String line; + // 逐行读取文件 + while ((line = reader.readLine()) != null) { + line = line.trim(); // 去除行首尾空白字符 + if (line.isEmpty()) { + continue; // 如果行为空,则跳过 + } + try { + // 处理逗号分隔的数字并添加到列表 + String[] values = line.split(","); + for (String value : values) { + try { + doubleList.add(Double.parseDouble(value.trim())); // 将每个值转换为 double 并添加 + } catch (NumberFormatException e) { + // 如果某个值无法转换为 double,记录并跳过 + System.err.println("Skipping invalid value: " + value); + } + } + } catch (Exception e) { + // 如果整行的格式不对,跳过这行 + System.err.println("Skipping invalid line: " + line); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + + // 将 List 转换为 double[] 数组 + double[] result = new double[doubleList.size()]; + for (int i = 0; i < doubleList.size(); i++) { + result[i] = doubleList.get(i); + } + + return result; + } + + /** * float数组转byte数组 * @param floatArray diff --git a/src/test/java/com/guwan/backend/ScoreProcessor.java b/src/test/java/com/guwan/backend/ScoreProcessor.java new file mode 100644 index 0000000..d9a53b0 --- /dev/null +++ b/src/test/java/com/guwan/backend/ScoreProcessor.java @@ -0,0 +1,117 @@ +package com.guwan.backend; + +import java.io.*; +import java.util.*; +import java.util.regex.*; + +public class ScoreProcessor { + + public static void main(String[] args) { + String inputFilePath = "D:\\00_桌面\\今日识别.txt"; // 输入日志文件路径 + List scores = extractScoresFromFile(inputFilePath); // 提取分数 + + // 将分数 * 100 + List scaledScores = scaleScores(scores); + + // 计算平均分,最高分,最低分 + double averageScore = calculateAverage(scaledScores); + int maxScore = Collections.max(scaledScores); + int minScore = Collections.min(scaledScores); + + // 计算每10分区间的出现概率 + Map scoreDistribution = calculateScoreDistribution(scaledScores); + + System.out.println("今日总次数:"+scaledScores.size()); + + // 输出结果 + System.out.println("平均分: " + averageScore); + System.out.println("最高分: " + maxScore); + System.out.println("最低分: " + minScore); + + System.out.println("每10分区间的出现概率:"); + for (Map.Entry entry : scoreDistribution.entrySet()) { + + String formattedProbability = String.format("%.3f", entry.getValue() / (double) scaledScores.size()); + + System.out.println(entry.getKey() + ": " + Double.parseDouble(formattedProbability) * 100 + "%"); + } + } + + /** + * 从日志文件中提取分数 + * + * @param filePath 文件路径 + * @return 提取的分数列表 + */ + public static List extractScoresFromFile(String filePath) { + List scores = new ArrayList<>(); + String pattern = "本次识别分数:([0-9]+\\.[0-9]+)"; // 匹配分数的正则表达式 + + try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { + String line; + Pattern r = Pattern.compile(pattern); + + while ((line = reader.readLine()) != null) { + Matcher m = r.matcher(line); + if (m.find()) { + scores.add(Double.parseDouble(m.group(1))); // 提取分数并添加到列表 + } + } + } catch (IOException e) { + e.printStackTrace(); + } + + return scores; + } + + /** + * 将分数乘以 100 + * + * @param scores 原始分数列表 + * @return 乘以 100 后的分数列表 + */ + public static List scaleScores(List scores) { + List scaledScores = new ArrayList<>(); + for (Double score : scores) { + scaledScores.add((int) (score * 100)); // 乘以 100 后转为整数 + } + return scaledScores; + } + + /** + * 计算平均分 + * + * @param scores 分数列表 + * @return 平均分 + */ + public static double calculateAverage(List scores) { + double sum = 0; + for (int score : scores) { + sum += score; + } + return sum / scores.size(); + } + + /** + * 计算每10分区间的出现次数 + * + * @param scores 分数列表 + * @return 每10分区间的出现次数 + */ + public static Map calculateScoreDistribution(List scores) { + Map distribution = new HashMap<>(); + + for (int score : scores) { + int rangeStart = (score / 10) * 10; // 计算所在的区间 + int rangeEnd = rangeStart + 9; + + // 生成区间字符串 + String range = rangeStart + "-" + rangeEnd; + + // 记录每个区间的出现次数 + distribution.put(range, distribution.getOrDefault(range, 0) + 1); + } + + return distribution; + } +} diff --git a/src/test/java/com/guwan/backend/TxtFilter.java b/src/test/java/com/guwan/backend/TxtFilter.java new file mode 100644 index 0000000..c8b2c4a --- /dev/null +++ b/src/test/java/com/guwan/backend/TxtFilter.java @@ -0,0 +1,60 @@ +package com.guwan.backend; + +import java.io.*; +import java.util.*; + +public class TxtFilter { + + public static void main(String[] args) { + // 输入文件路径和输出文件路径 + String inputFilePath = "D:\\00_桌面\\logback_error.log"; + String outputFilePath = "D:\\00_桌面\\a.txt"; + + // 调用方法,获取只包含 "本次识别分数" 的行 + List filteredLines = filterLinesContainingScore(inputFilePath); + + // 将筛选后的行写入新文件 + writeToFile(filteredLines, outputFilePath); + + // 输出筛选的行(可选) + filteredLines.forEach(System.out::println); + } + + /** + * 读取文件并过滤出包含“本次识别分数”字符串的行 + * + * @param inputFilePath 输入文件路径 + * @return 只包含“本次识别分数”字符串的行列表 + */ + public static List filterLinesContainingScore(String inputFilePath) { + List result = new ArrayList<>(); + try (BufferedReader reader = new BufferedReader(new FileReader(inputFilePath))) { + String line; + while ((line = reader.readLine()) != null) { + if (line.contains("本次识别分数")) { // 检查行是否包含目标字符串 + result.add(line); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + return result; + } + + /** + * 将筛选后的行写入文件 + * + * @param lines 要写入的行列表 + * @param outputFilePath 输出文件路径 + */ + public static void writeToFile(List lines, String outputFilePath) { + try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputFilePath))) { + for (String line : lines) { + writer.write(line); + writer.newLine(); // 写入换行符 + } + } catch (IOException e) { + e.printStackTrace(); + } + } +}