Spaces:
Sleeping
Sleeping
lovelyai999
commited on
Commit
•
8c3133c
1
Parent(s):
5396799
Update myEmbedding.py
Browse files- myEmbedding.py +0 -61
myEmbedding.py
CHANGED
@@ -574,64 +574,3 @@ EmbeddingConcept =lambda x :ConceptNetwork.embeds(x).tolist()[0]
|
|
574 |
|
575 |
|
576 |
|
577 |
-
def updateWiki():
|
578 |
-
import random
|
579 |
-
from fileDict3 import FileDict
|
580 |
-
wiki=FileDict(Gbase+"wikipedia.sql3")
|
581 |
-
wikiConcept=FileDict(Gbase +"wikipediaConceptA.sql3")
|
582 |
-
random.seed(time.time())
|
583 |
-
|
584 |
-
n=800*100*100
|
585 |
-
startIndex=len(list(wikiConcept.keys()))
|
586 |
-
|
587 |
-
#f1=open("testBuildTree.txt" , "w" ,encoding="utf-8")
|
588 |
-
#f2=open("testConceptTreeSentence.txt" , "w" ,encoding="utf-8")
|
589 |
-
m=0
|
590 |
-
for x ,(k,v) in enumerate(wiki.items()):
|
591 |
-
if x <startIndex:continue
|
592 |
-
#k,v=next(items)
|
593 |
-
#if random.randint(1,3000)!=10 :continue
|
594 |
-
#m+=1
|
595 |
-
#if m>1000 :break
|
596 |
-
if x%5==0 and IN_COLAB:google.colab.output.clear()
|
597 |
-
its=[]
|
598 |
-
text=k +"\n"+v
|
599 |
-
t0=time.time ()
|
600 |
-
print(Text.Cyan(k))
|
601 |
-
try:
|
602 |
-
conceptTree=ConceptNetwork.generate_concept_tree(text,split_sentences=True,top_n=0)
|
603 |
-
|
604 |
-
s2=format_concept_tree(tree=conceptTree,max_depth=16)
|
605 |
-
print (s2[:2048])
|
606 |
-
wikiConcept[k]=s2
|
607 |
-
#json.dumps (conceptTree)
|
608 |
-
except:
|
609 |
-
print (v)
|
610 |
-
import traceback
|
611 |
-
traceback.print_exc()
|
612 |
-
t=time.time ()-t0
|
613 |
-
print(Text.Cyan(x) ,Text.LightYellow(t))
|
614 |
-
if x%100000==0 and x>startIndex+90000:
|
615 |
-
wikiConcept._commit()
|
616 |
-
wikiConcept.close()
|
617 |
-
drive.flush_and_unmount()
|
618 |
-
drive.mount('/gdrive',force_remount=True)
|
619 |
-
return 1
|
620 |
-
return 0
|
621 |
-
|
622 |
-
|
623 |
-
#f1.write(k+":\n"+s1+"\n")
|
624 |
-
#f2.write(k+":\n"+s2+"\n")
|
625 |
-
#f1.close()
|
626 |
-
#f2.close()
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
if __name__ == '__main__' :
|
632 |
-
while True :
|
633 |
-
if not updateWiki():break
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
|
|
574 |
|
575 |
|
576 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|