<commit_before>import os
import sys

from morenines.index import Index
from morenines.util import get_files, get_hash

def create(root_path):
    index = Index(root_path)

    files = get_files(root_path)

    for path in files:
        # To hash the file, we need its absolute path
        abs_path = os.path.join(root_path, path)

        hash_ = get_hash(abs_path)

        # We store the relative path in the index
        index.add(path, hash_)

    index.write(sys.stdout)<commit_msg>Make create.create() return index instead of writing<commit_after>import os

from morenines.index import Index
from morenines.util import get_files, get_hash

def create(root_path):
    index = Index(root_path)

    files = get_files(root_path)

    for path in files:
        # To hash the file, we need its absolute path
        abs_path = os.path.join(root_path, path)

        hash_ = get_hash(abs_path)

        # We store the relative path in the index
        index.add(path, hash_)

    return index
{'fraction_non_alphanumeric': 0.0712136409227683, 'fraction_numerical': 0.0, 'mean_word_length': 2.9760956175298805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6917190', 'n_tokens_mistral': 313, 'n_tokens_neox': 301, 'n_words': 100}