from nltk.tokenize import sent_tokenize

def lines(a, b): """Return lines in both a and b"""

return list(set(a.split('\n').intersection(b.split('\n'))))

def sentences(a, b): """Return sentences in both a and b"""

return list(set(sent_tokenize(a).intersection(sent_tokenize(b))))

def sub_str_token(str, n): substrings = [] for s in range(len(str) -n + 1): substrings.append(str[s:s + n])

return substrings

def substrings(a, b, n): """Return substrings of length n in both a and b"""

return list(set(sub_str(a, n).intersection(sub_str(b, n))))
  • How do you call that? Do the two text files actually exist in the right directory? – Blauelf Nov 13 '18 at 13:21
  • Oh no! I did not create them. That is why the program did not read one of this files . Now I got where I did wrong. Thank you very much. – Bethuel Mavhungu Nov 13 '18 at 14:23

There seems to have been some confusion on how to call the programme.

Both, the web interface, and the command-line interface as described in the "Testing" chapter, require passing two existing text files with the lines/sentences/strings to compare.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .