def euclidean(txt):

    a = task()

    Ques = a[:len(a) // 2]
    Ans = a[len(a) // 2:]
    n = 0
    text_input = [n]
    text_input[0] = word_tokenize(txt)
    #text_input[0] = word_tokenize(u"آپ کے جوتے")
    new_corpus = text_input + Ques

    transformed_results = transform(new_corpus)
    #print('EUCLIDEAN SIMILARITY')
    #print('Master Sentence: %s' % new_corpus[0])
    score1 = []
    news_headline1 = []
    ind = []
    for i, news_headline in enumerate(new_corpus):
        score = sklearn.metrics.pairwise.euclidean_distances(
            [transformed_results[i]], [transformed_results[0]])[0][0]
        if score > 0:
            #print('-----')
            score1.append(score)
            #print(score1)
            ind = i
            print(transformed_results[i])
            news_headline1.append(news_headline)
            print('Score: %.2f, Index  %d,Comparing Sentence: %s' %
                  (score, ind, news_headline))
    return Ans[(score1.index(min(score1)))]
def backend(txt):
    a = task()

    Ques = a[:len(a) // 2]
    Ans = a[len(a) // 2:]
    n = 0
    text_input = [n]
    text_input[0] = word_tokenize(txt)
    #text_input[0] = word_tokenize(u"آپ کے جوتے")
    new_corpus = text_input + Ques

    transformed_results = transform(new_corpus)
    transformed_cosine = transform(new_corpus)
    return euclidean(transformed_results)
def distance(txt):
    a = task()
    index = 0
    max = 0
    Ques = a[:len(a) // 2]
    Ans = a[len(a) // 2:]
    user_ques = word_tokenize(txt)
    for i, single_question in enumerate(Ques):
        count = 0
        for token in user_ques:
            for eachtoken in single_question:
                if (token == eachtoken):
                    count = count + 1

        if (count > max):
            max = count
            index = i
    return Ans[index]
# Removes Stopwords from the given list and returns a new list
# Author  : Syed Awais Kazmi
# COMSATS : SP15-R01-009

# List of 203 stopwords list
# encoding = utf-8
from task1_ import array_questions
from multi import task
from nltk import word_tokenize

a = task()

stopwords = [
    "بلکہ", "بعض", "ہوں", "بڑی", "بعد", "بہت", "بھی", "بے", "پاس", "پہلے",
    "پر", "پھر", "تا", "ہیں", "تاکہ", "تب", "تجھ", "تجھے", "تک", "تمام",
    "تمہارا", "تمہارے", "تم", "تمھارے", "تمہاری", "تمھیں", "تمہیں", "تھا",
    "تھے", "تھی", "تھیں", "تو", "تیری", "تیرے", "جا", "جاتا", "جاتی", "جاتے",
    "جاتی", "جانی", "جانے", "جاؤ", "جائے", "جائیں", "جب", "جس", "جن", "ساتھ",
    "جنہوں", "جنہیں", "جو", "جیسا", "جیسے", "جیسی", "جیسوں", "چاہیئے", "چلا",
    "چاہے", "چونکہ", "حالاں", "حالانکہ", "دو", "دونوں", "دوں", "دے", "دی",
    "دیا", "دیں", "ہوں", "دیے", "دیتا", "دیتے", "دیتی", "دینا", "دینے", "دینی",
    "دیئے", "ڈالا", "ڈالنا", "رہتے", "رہنا", "رہنے", "رہتی", "رہنی", "رہو",
    "رہے", "رہی", "رہیں", "زیادہ", "سا", "سامنے", "سب", "سکتا", "سو", "سے",
    "سی", "شاید", "صرف", "طرح", "طرف", "عین", "کا", "کبھی", "کچھ", "کہہ", "کر",
    "کرتا", "کرتے", "کرتی", "کرنا", "کرنے", "کرو", "کروں", "کرے", "کریں", "کس",
    "کسے", "کسی", "کہ", "کہا", "کو", "کہے", "کون", "کوئی", "کے", "کی", "کیا",
    "کیسے", "کیونکہ", "کیوں", "کیے", "کئے", "گا", "گویا", "گے", "گی", "گیا",
    "گئے", "گئی", "لا", "لاتا", "لاتے", "لاتی", "لانا", "لانے", "لانی", "لایا",
    "لائے", "لائی", "لگا", "لگے", "لگی", "لگیں", "لو", "لے", "لی", "لیا",
    "لیتا", "لیتے", "لیتی", "لیکن", "لیں", "لیے", "لئے", "مجھ", "مجھے", "مگر",
    "میرا", "میرے", "میری", "میں", "نا", "نہ", "نہایت", "نہیں", "نے", "ہر",
示例#5
0
from nltk.util import ngrams
from multi import task
from task1_ import array_questions
import nltk, re, string, collections
import nltk
from ngram import NGram

c = task()
cor = array_questions()

Ques = c[:len(c) // 2]
Ans = c[len(c) // 2:]
n = 0
se = [n]
se[0] = nltk.word_tokenize("پاکستان")
tex = se + Ques
print(tex)

grams = {}
words = 3

for k, i in enumerate(tex):
    v = NGram(i)


def comp(sa):
    for l in v.search(se, threshold=0.1):
        print("output:: ", l[0], "Next", l[1])


print(comp(se))