Beispiel #1
0
 def _build_stopper(self, path):
     self.stopper = build_stopper(path)
Beispiel #2
0
    content = content.lower()
    content = content.replace('\n', ' ')

    return {'type': page_type, 'title': title, 'path': unicode(rel_path), 'content': content, 'keyword': keyword}



# Build the index
if not os.path.isdir(index_dir):
    os.makedirs(index_dir)

db = xapian.WritableDatabase(index_dir, xapian.DB_CREATE_OR_OPEN)

# Build the Stopper

stopper = build_stopper(sw_file)

termgenerator = xapian.TermGenerator()
termgenerator.set_stemmer(xapian.Stem('en'))
termgenerator.set_stopper(stopper)

# Count the number of files
file_count = 0
for dirpath, dirnames, filenames in os.walk(document_dir):
    file_count += len(filenames)
file_count = float(file_count)

# Index the files
count = 0
for dirpath, dirnames, filenames in os.walk(document_dir):
    for path in filenames: