今天看到这样一个题:
请统计出以下这段文字中,出现频率最高的二元字符(两个字符)的组合。
(举例:在字符串“1252336528952”中,二元字符组合“52”出现3次,频率最高。)
oneofthecentralresultsofairesearchinthe1970swasthattoachievegoodperformanceaisystemsmusthav
elargeamountsofknowledgeknowledgeispowertheslogangoeshumansclearlyusevastamountsofknowledge
andifaiistoachieveitslongtermgoalsaisystemsmustalsousevastamountssincehandcodinglargeamount
sofknowledgeintoasystemisslowtediousanderrorpronemachinelearningtechniqueshavebeendeveloped
toautomaticallyacquireknowledgeoftenintheformofifthenrulesproductionsunfortunatelythishasof
tenledtoautilityproblemminton1988bthelearninghascausedanoverallslowdowninthesystemforexampl
einmanysystemslearnedrulesareusedtoreducethenumberofbasicstepsthesystemtakesinordertosolvep
roblemsbypruningthesystemssearchspaceforinstancebutinordertodetermineateachstepwhichrulesar
eapplicablethesystemmustmatchthemagainstitscurrentsituationusingcurrenttechniquesthematcher
slowsdownasmoreandmorerulesareacquiredsoeachsteptakeslongerandlongerthisectcanoutweighthere
ductioninthenumberofstepstakensothatthenetresultisaslowdownthishasbeenobservedinseveralrece
ntsystemsminton1988aetzioni1990tambeetal1990cohen1990ofcoursetheproblemofslowdownfromincrea
singmatchcostisnotrestrictedtosystemsinwhichthepurposeofrulesistoreducethenumberofproblemso
lvingstepsasystemacquiringnewrulesforanypurposecanslowdowniftherulessignicantlyincreasethem
atchcostandintuitivelyoneexpectsthatthemoreproductionsthereareinasystemthehigherthetotalmat
chcostwillbethethesisofthisresearchisthatwecansolvethisprobleminabroadclassofsystemsbyimpro
vingthematchalgorithmtheyuseinessenceouraimistoenablethescalingupofthenumberofrulesinproduc
tionsystemsweadvancethestateoftheartinproductionmatchalgorithmsdevelopinganimprovedmatchalg
orithmwhoseperformancescaleswellonasignicantlybroaderclassofsystemsthanexistingalgorithmsfu
rthermorewedemonstratethatbyusingthisimprovedmatchalgorithmwecanreduceoravoidtheutilityprob
leminalargeclassofmachinelearningsystems
我觉的这道题很有意思,以前写过c语言的实现,现在用java来解决这个问题,直接看代码:
package com.company;
import java.io.*;
import java.util.*;
import java.util.List;
/**
* * @projectName test
* * @title Test3
* * @package com.company
* * @description 查找字符串中出现最多的子类
* * @author IT_CREAT
* * @date 2020 2020/5/24/024 22:32
* * @version 1.0.0
*/
public class Test3 {
/**
* 待测试的字符串
*/
public static String testTtr = "oneofthecentralresultsofairesearchinthe1970swasthattoachievegoodper" +
"formanceaisystemsmusthavelargeamountsofknowledgeknowledgeispowertheslogangoeshumansclearly" +
"usevastamountsofknowledgeandifaiistoachieveitslongtermgoalsaisy