原创应用,转载请注明出处
https://blog.youkuaiyun.com/gkbxs/article/details/116071060
学习的时候遇到一个新词A,然后这个新词A学习中又学到了新词B,学习B的时候又学习到了C,不断类推。知识也是有传递过程的,所以我用python来做了这么一个知识联想发散的功能。整个功能用了我自己创造的知识处理库的其他函数。
代码复制无用,因为用了我自己创造的一个库哦
def Spread_knowledge(filepath):
para,con=getparagraphsandcontent(filepath,qukongge=False)
alltime=[]
bcontinue=False
while not bcontinue:
if len(alltime)==0:
print('本轮第一次,没有历史')
allget=[]
B=set(allget)
else:
print('已经迭代过的词汇:',alltime)
allrule=lab2rule(alltime)
allget=matchforline2(allrule,para)
B=set(allget)
the_next=input('请输入本轮关键词 ')
this=[]
this.append(the_next)
print(this)
thisrule=lab2rule(this)
thisget=matchforline2(thisrule,para)
A=set(thisget)
C=A-B
print(C)
choose=input('是否继续联想发散,是输入y,否则输入n ')
if choose=='y':
alltime.append(the_next)
bcontinue=False
elif choose=='n':
bcontinue=True
break
else:
choose=input('是否继续联想发散,是输入y,否则输入n ')