Beispiel #1
0
def corpus_statistics(root_path, categories):
    statistics = dc(dict)
    for category in categories:
        path = os.path.join(root_path, category)
        for corpus in os.listdir(path):
            if corpus.endswith(suffix):
                statistics[category], statistics[category]["total"] = \
                    count_tweets(os.path.join(path, corpus))
    return dict(statistics)
Beispiel #2
0
    def __init__(self, no_of_topics=10, scan=False):
        self.file_path = None
        self.text = None
        self.url = None
        self.no_of_topics = no_of_topics
        self.scan = scan
        #self.no_of_sent=None
        #self.positive_count
        stopword_ = pd.read_pickle(directory +
                                   '\\Text\\dictionary\\text_stopwords.pkl')
        positive_dict = pd.read_pickle(directory +
                                       '\\Text\\dictionary\\text_pos.pkl')
        negative_dict = pd.read_pickle(directory +
                                       '\\Text\\dictionary\\text_neg.pkl')
        constraints = pd.read_pickle(
            directory + '\\Text\\dictionary\\text_constraints.pkl')
        uncertain = pd.read_pickle(directory +
                                   '\\Text\\dictionary\\text_uncertain.pkl')

        # stopword_=pd.read_pickle('C:\\Users\\vishu\\OneDrive\\Desktop\\Vishal\\final year project\\Text-analysis~\\Final_project_Server-main\\Text\\dictionary\\text_stopwords.pkl')
        # positive_dict=pd.read_pickle('C:\\Users\\vishu\\OneDrive\\Desktop\\Vishal\\final year project\\Text-analysis~\\Final_project_Server-main\\Text\\dictionary\\text_pos.pkl')
        # negative_dict=pd.read_pickle('C:\\Users\\vishu\\OneDrive\\Desktop\\Vishal\\final year project\\Text-analysis~\\Final_project_Server-main\\Text\\dictionary\\text_neg.pkl')
        # constraints=pd.read_pickle('C:\\Users\\vishu\\OneDrive\\Desktop\\Vishal\\final year project\\Text-analysis~\\Final_project_Server-main\\Text\\dictionary\\text_constraints.pkl')
        # uncertain=pd.read_pickle('C:\\Users\\vishu\\OneDrive\\Desktop\\Vishal\\final year project\\Text-analysis~\\Final_project_Server-main\\Text\\dictionary\\text_uncertain.pkl')
        self.stopwords = dc(int)
        self.positive_dict_13 = dc(int)
        self.negative_dict_13 = dc(int)
        self.constraints_dict = dc(int)
        self.uncertain_dict = dc(int)
        for i in stopword_:
            self.stopwords[i] = 1
        for i in positive_dict:
            self.positive_dict_13[i] = 1
        for i in negative_dict:
            self.negative_dict_13[i] = 1
        for i in constraints:
            self.constraints_dict[i] = 1
        for i in uncertain:
            self.uncertain_dict[i] = 1
Beispiel #3
0
from collections import Counter as cs
from collections import defaultdict as dc

x = input().split(" ")
x = list(map(int, x))
for i in range(len(x)):
    l1 = []
    d = dc()
    for j in range(x[i]):
        y = input()
        d[j + 1] = y
        l1.append(y)
    print(l1)
    print(d)
    print(cs(l1))
    a = cs(l1)
    for k, v in a.items():
        if v != 1:
            for i in d.keys():
                if d[i] == k:
                    print(i, end="")
        print()
'''5 2
a
b
a
a
b
['a', 'b', 'a', 'a', 'b']
defaultdict(None, {1: 'a', 2: 'b', 3: 'a', 4: 'a', 5: 'b'})
Counter({'a': 3, 'b': 2})
Beispiel #4
0
from collections import defaultdict as dc 
t=lambda:map(int,input().split())
n,x=t()
a=list(t())
d=dc(list)
for i in range(n):
    d[a[i]]+=[i+1]
for i in d:
    for j in d:
        a=b=0
        k=x-i-j
        if k not in d:
            continue
        
        if i==k:
            if len(d[i])==1:
                continue
            b=1
        if j==k:
            if len(d[j])==1:
                continue
            b=1
        if i==j:
            if len(d[i])==1 or (len(d[i])==2 and i==k):
                continue
            elif i==k:
                b=2
            a=1
                
        print(d[i][0],d[j][a],d[k][b])
        exit()