-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindexesInit.py
40 lines (35 loc) · 1.08 KB
/
indexesInit.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
import constants
import sys
import os
import shutil
import helperFunctions
def main():
#if os.path.exists(constants.allCollsDir):
# shutil.rmtree(constants.allCollsDir)
createIndexStructure()
createFile(constants.docFile)
createFile(constants.docCacheFile)
createFile(constants.termsFile)
createFile(constants.fSortedTermIndex)
createFile(constants.collFile)
createFile1(constants.SortedCacheIndex)
def createIndexStructure():
createDir(constants.allCollsDir)
createDir(constants.indexDir)
createDir(constants.termsDir)
def createDir(sDir):
sNewpath = sDir
if not os.path.exists(sNewpath):
os.makedirs(sNewpath)
def createFile(fileName):
with open(fileName, "w") as f:
f.write(helperFunctions.makeFixedLengthSpace("\n",constants.docSize))
f.close()
def createFile1(fileName):
with open(fileName, "w") as f:
f.write(helperFunctions.makeFixedLengthSpace("\n",18))
f.close()
#To delete all the unnecessary files
def cleanup():
shutil.rmtree(constants.termsDir)
#os.remove(constants.fSortedTermIndex)