0
from nltk.tokenize import sent_tokenize

def lines(a, b):
    s = set()
    a1 = set(a.split('\n'))
    b1 = set(b.split("\n"))
    for i in a1:
        if i in b1:
             s.add(i)
    return [list(s)]

  def sentences(a, b):
     s = set()
     a1 =set(a.sent_tokenize)
     b1 =set(b.sent_tokenize)
    for i in a1:
         if i in b1:
            s.add(i)
     return [list(s)]

def substrings(a, b, n):
    s1 = set()
    s2 = set()
    a1 = a.split()
    b1 = b.split()
    i = 0
    l = list()

    for word in a1 :
         if i <= len(word) - 1 - n:
             s1.add(word[i: i + n])
             i = i + 1

    for word in b1 :
        if i <= len(word) - 1 - n:
             s2.add(word[i: i + n])
             i = i + 1

    for substr in s1 and s2:
         l.append(substr)

     return [l]
1

You don't mention what the error is, but more than likely it's caused by you returning a list inside a list. If list(s) returns a list, then [list(s)] returns a list containing one list. You should simply return the list.

1
  • oh yes , thanks. – user21692 Jul 1 '18 at 10:59

You must log in to answer this question.

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