<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Counting Tales
Towards an Algorithmic Analysis of Folk Narratives
Counting Texts
In the code below, we use os.walk which returns a tuple that contains the location and all its contents (both directories and files). The tuple in this case looks like this
Step1:  For the record, here are our texts
Step2:  Let's get some basic information about these texts
<ASSISTANT_TASK:>
Python Code:
import os
fileCount = len(os.walk('./texts').next()[2])
print(fileCount)
Explanation: Counting Tales
Towards an Algorithmic Analysis of Folk Narratives
Counting Texts
In the code below, we use os.walk which returns a tuple that contains the location and all its contents (both directories and files). The tuple in this case looks like this:
('./texts', [], ['anc-088.txt', 'anc-089.txt', 'anc-090.txt', 'anc-091.txt', 'bro-001.txt', 'bro-002.txt', 'bro-003.txt', 'bro-004.txt', 'lau-013.txt', 'lau-014.txt', 'loh-157.txt', 'loh-158.txt', 'loh-159.txt', 'loh-160.txt', 'loh-161.txt', 'loh-162.txt', 'loh-162b.txt', 'loh-163.txt', 'loh-164.txt', 'loh-165.txt', 'uls-001.txt', 'uls-002.txt', 'uls-003.txt'])
Here, the path is the one we provided, ./texts and it contains no directories, only these files. The list of files is in the third position of the tuple -- the number 2 when counting from zero -- and we get to it with .next(). Our focus is only on the length of that list: 23.
End of explanation
print(os.walk('./texts').next()[2])
Explanation: For the record, here are our texts:
End of explanation
import glob
import re
files = {}
for fpath in glob.glob("./texts/*.txt"):
    with open(fpath) as f:
         fixed_text = re.sub("[^a-zA-Z'-]"," ",f.read())
    files[fpath] = (len(fixed_text.split()),len(set(fixed_text.split())))
for fname in sorted(files):
    print fname + '\t' + str(files[fname][0]) + '\t' + str(files[fname][1])
Explanation: Let's get some basic information about these texts: how long they are and how many unique words occur in each one:
End of explanation
<END_TASK>