Exemplo n.º 1
0
def summarize(text, topic):
    # Parse the document with spaCy
    #doc = textacy.make_spacy_doc(text)
    doc = nlp(str(text))

    # Extract semi-structured statements
    entities = textacy.extract.entities(doc)

    summary = []
    ent = []
    accuracy = 100

    for entity in entities:
        ent.append(entity)

    split_it = str(ent).split()

    Counter = co(split_it)

    most_occur = Counter.most_common(1)[0][0].replace(',', '')
    if not most_occur:
        statements = textacy.extract.semistructured_statements(doc, topic)
    else:
        statements = textacy.extract.semistructured_statements(doc, most_occur)

    print(most_occur)
    for statement in statements:
        #print(str(statement) + "\n")
        summary.append(statement)
    return str(summary), accuracy
Exemplo n.º 2
0
    def check_intersect(self):
        current = self.head
        flag = False
        index_value = 0
      
        while current:
            while index_value < len(arr) and current.data > arr[index_value]: 
                index_value += 1
            if index_value < len(arr) and current.data == arr[index_value]:
                flag = True 
                result.append(current.data)

            current = current.next 

        if flag == False: 
            print("NO INTERSECTION")
            exit()
        print(*co(result))
Exemplo n.º 3
0
def awakencomp(ID1, ID2):

    info1 = info(ID1)
    info2 = info(ID2)
    m1_awks=info(ID1)[4]
    m2_awks=info(ID2)[4]
    common_awks = awaken_translator(list((co(m1_awks) & co(m2_awks)).elements()))
    m1_unique_awks = list((co(awaken_translator(m1_awks)) - co(common_awks)).elements())
    m2_unique_awks = list((co(awaken_translator(m2_awks)) - co(common_awks)).elements())

    yield 'Common awakens: '+str(common_awks)
    yield str(info(ID1)[0])+' unique awakens: '+str(m1_unique_awks)
    yield str(info(ID2)[0])+' unique awakens: '+str(m2_unique_awks)
Exemplo n.º 4
0
def awakencomp(ID1, ID2):

    info1 = info(ID1)
    info2 = info(ID2)
    m1_awks = info(ID1)[4]
    m2_awks = info(ID2)[4]
    common_awks = awaken_translator(
        list((co(m1_awks) & co(m2_awks)).elements()))
    m1_unique_awks = list(
        (co(awaken_translator(m1_awks)) - co(common_awks)).elements())
    m2_unique_awks = list(
        (co(awaken_translator(m2_awks)) - co(common_awks)).elements())

    yield 'Common awakens: ' + str(common_awks)
    yield str(info(ID1)[0]) + ' unique awakens: ' + str(m1_unique_awks)
    yield str(info(ID2)[0]) + ' unique awakens: ' + str(m2_unique_awks)
Exemplo n.º 5
0
##for i in range(int(input())):
##    n,m,k = [int(j) for j in input().split()]
##    for j in range(n):
##        p = [int(k) for k in input().split()]
##        pp = co(p)
##        if(len(pp.most_common(10000))>1 and pp.most_common(2)[0][1]==pp.most_common(2)[1][1]):
##            print(pp.most_common(10000)[1][0], end=' ')
##        else:
##            print(pp.most_common(10000)[0][0], end=' ')
##

for i in range(int(input())):
    n, m, k = [int(j) for j in input().split()]
    a = [0 for j in range(k)]
    pp = []
    for j in range(n):
        p = [int(k) for k in input().split()]
        pp.append(p)
        q = dict(co(p))
        s = max(list(q.values()))
        qq = set()
        for k in list(q.keys()):
            if (q[k] == s):
                qq.add(k)
        for k in range(len(p)):
            if (p[k] in qq):
                a[k] += 1
    k = a.index(max(a))
    for j in range(n):
        print(pp[j][k], end=' ')
Exemplo n.º 6
0
from collections import Counter as co

t, n = map(int, input().split())
l = []
for i in range(t):
    l.append(list(input()))
l1 = list(zip(*l))
#print(l1)
s = ""
for i in l1:
    c = co(sorted(i))
    s += c.most_common(1)[0][0]
print(s)
Exemplo n.º 7
0

d = [4,6,3]*10
d.count(4)


# (e) [4,6,3, 4,6,3,...,4,6,3,4] where there are 11 occurrences of 4, 10 occurrences of 6 and 10 occur- 
# rences of 3. 

# In[ ]:


e = [4,6,3]*11
del e[-1]
from collections import Counter as co
co(e)


# 2. Create a list of the values of:  𝑒𝑥 cos(𝑥) for x=3, 3.1, 3.2, … 6.   

# In[ ]:


import numpy as np
x = np.arange(3,6.1,0.1)
re = [np.exp(i)*np.cos(i) for i in x]
re


#  Create a list of the values of: 
Exemplo n.º 8
0
from collections import Counter as co, deque as dq
for _ in range(int(input())):
    n, k = map(int, input().split())
    c = list(map(int, input().split()))
    ans = 0
    mc = max([x for x in co(c).items()], key=lambda x: x[1])
    i = 0
    while i < n:
        if c[i] != mc[0]:
            ans += 1
            i += k
        elif i + k >= n:
            for _ in range(i, n):
                if c[i] != mc[0]:
                    ans += 1
                    break
            break
        else:
            i += 1
    print(ans)
Exemplo n.º 9
0
from collections import Counter as co

for t in range(int(raw_input())):
    no = int(raw_input())
    inp = map(int, raw_input().split())
    setinp = co(inp)
    flag = False
    for val in setinp.values():
        if val >= 3:
            print "Yes"
            flag = True
            break
    if not flag:
        print "No"
def mode(A):
    from collections import Counter as co
    lis = co(A).most_common()

    return min([lis[0][0]] + [i for i, j in lis[1:] if j == lis[0][1]])
Exemplo n.º 11
0
from collections import Counter as co
for _ in range(int(input())):
    x, y = map(int, input().split())
    c = list(input())
    count_of_commands = co(c)
    cx = cy = 0
    for i in c:
        if i == 'R': cx += 1
        if i == 'L': cx -= 1
        if i == 'U': cy += 1
        if i == 'D': cy -= 1

    ans = "NO"
    if cx < x:
        if count_of_commands['L'] >= x - cx:
            cx = x
    if cx > x:
        if count_of_commands['R'] >= cx - x:
            cx = x
    if cy > y:
        if count_of_commands['U'] >= cy - y:
            cy = y
    if cy < y:
        if count_of_commands['D'] >= y - cy:
            cy = y

    if cx == x and cy == y:
        ans = "YES"

    print(ans)
    def __init__(self, a = 0, b = 1):
        self.a = a
        self.b = b

    def __str__(self):
        s = "{0} {1}".format(self.a, self.b)
        return s



while l < len(arr) - 1 and r < len(arr):
    curr_arr = []
    curr_arr.append(arr[l])
    curr_arr.append(arr[r])

    count_arr = co(curr_arr)
    #print(len(count_arr))
    print()

    # print(l, r)
    print(arr[l], arr[l])

    if len(count_arr) <= 2 and abs(curr_arr[0] - curr_arr[1]) <= 1:
        print("Okay")
        r += 1
        set_arr.append(Node(l + 1, r + 1))

    else:
        l += 1

for i in range(len(set_arr)):
Exemplo n.º 13
0
from collections import Counter as co

arr = [2, 2, 1]
arr = co(arr)

for i in arr:
    if arr[i] == 1:
        print(i)