#!/usr/bin/python
# -*- coding: utf-8 -*-
from pymongo import MongoClient

import re, sys

client = MongoClient('hawking.sv.cmu.edu', 27019)



def helper():
	print('''
%s summary.txt
		''' % (sys.argv[0]))


def summary(input_summay_file, src_coll, dst_coll):
	topic_map = {}

	with open(input_summay_file, 'r') as f:
		topic_name = None
		topic_keywords = []
		for line in f.readlines():
			if line.strip() == '' or line.strip() == '\n':
				continue
			else:
				# print line
				if line.startswith('\t'):  # second hierarchical topic
					topic_keywords.append(line.strip().split("\t")[0])
					# print topic_keywords
				else: # first hierarchical topic 
					if topic_name is not None:
						topic_map[topic_name] = {'topic': topic_name, 'keywords': list(topic_keywords), 'publication_counts': 0, 'publication_ids':[]}
					topic_name = line.split("\t")[0].replace('/', ' ')
					topic_keywords = []
	if topic_name is not None:
		# print topic_name
		topic_map[topic_name] = {'topic': topic_name, 'keywords': list(topic_keywords), 'publication_counts': 0, 'publication_ids':[]}

	for doc in src_coll.find():
		paper_id = doc['paper_id']
		for topic in doc['topics']:
			topic_name = topic['topic']
			
			# print topic_name
			topic_map[topic_name]['publication_counts'] += 1
			topic_map[topic_name]['publication_ids'].append(paper_id)

	# print topic_map
	dst_coll.drop()
	topic_id = 0
	for name in topic_map:
		# print topic_map[name]
		topic = topic_map[name]
		topic['topic_id'] = topic_id
		topic_id += 1
		dst_coll.insert_one(topic)


def runner(src_coll=client.nasa_publication.LLDA_topics, dst_coll=client.nasa_publication.topic_overview):
	if len(sys.argv) < 2:
		helper()
		exit(1)
	
	summary(sys.argv[1], src_coll, dst_coll)

if __name__ == "__main__":
	runner()






7222e1bd21e1150c8cefaa6f8feb746e0c1b76ea
<mask token>


def helper():
    print('\n%s summary.txt\n\t\t' % sys.argv[0])


def summary(input_summay_file, src_coll, dst_coll):
    topic_map = {}
    with open(input_summay_file, 'r') as f:
        topic_name = None
        topic_keywords = []
        for line in f.readlines():
            if line.strip() == '' or line.strip() == '\n':
                continue
            elif line.startswith('\t'):
                topic_keywords.append(line.strip().split('\t')[0])
            else:
                if topic_name is not None:
                    topic_map[topic_name] = {'topic': topic_name,
                        'keywords': list(topic_keywords),
                        'publication_counts': 0, 'publication_ids': []}
                topic_name = line.split('\t')[0].replace('/', ' ')
                topic_keywords = []
    if topic_name is not None:
        topic_map[topic_name] = {'topic': topic_name, 'keywords': list(
            topic_keywords), 'publication_counts': 0, 'publication_ids': []}
    for doc in src_coll.find():
        paper_id = doc['paper_id']
        for topic in doc['topics']:
            topic_name = topic['topic']
            topic_map[topic_name]['publication_counts'] += 1
            topic_map[topic_name]['publication_ids'].append(paper_id)
    dst_coll.drop()
    topic_id = 0
    for name in topic_map:
        topic = topic_map[name]
        topic['topic_id'] = topic_id
        topic_id += 1
        dst_coll.insert_one(topic)


def runner(src_coll=client.nasa_publication.LLDA_topics, dst_coll=client.
    nasa_publication.topic_overview):
    if len(sys.argv) < 2:
        helper()
        exit(1)
    summary(sys.argv[1], src_coll, dst_coll)


<mask token>

<mask token>


def helper():
    print('\n%s summary.txt\n\t\t' % sys.argv[0])


def summary(input_summay_file, src_coll, dst_coll):
    topic_map = {}
    with open(input_summay_file, 'r') as f:
        topic_name = None
        topic_keywords = []
        for line in f.readlines():
            if line.strip() == '' or line.strip() == '\n':
                continue
            elif line.startswith('\t'):
                topic_keywords.append(line.strip().split('\t')[0])
            else:
                if topic_name is not None:
                    topic_map[topic_name] = {'topic': topic_name,
                        'keywords': list(topic_keywords),
                        'publication_counts': 0, 'publication_ids': []}
                topic_name = line.split('\t')[0].replace('/', ' ')
                topic_keywords = []
    if topic_name is not None:
        topic_map[topic_name] = {'topic': topic_name, 'keywords': list(
            topic_keywords), 'publication_counts': 0, 'publication_ids': []}
    for doc in src_coll.find():
        paper_id = doc['paper_id']
        for topic in doc['topics']:
            topic_name = topic['topic']
            topic_map[topic_name]['publication_counts'] += 1
            topic_map[topic_name]['publication_ids'].append(paper_id)
    dst_coll.drop()
    topic_id = 0
    for name in topic_map:
        topic = topic_map[name]
        topic['topic_id'] = topic_id
        topic_id += 1
        dst_coll.insert_one(topic)


def runner(src_coll=client.nasa_publication.LLDA_topics, dst_coll=client.
    nasa_publication.topic_overview):
    if len(sys.argv) < 2:
        helper()
        exit(1)
    summary(sys.argv[1], src_coll, dst_coll)


if __name__ == '__main__':
    runner()

<mask token>
client = MongoClient('hawking.sv.cmu.edu', 27019)


def helper():
    print('\n%s summary.txt\n\t\t' % sys.argv[0])


def summary(input_summay_file, src_coll, dst_coll):
    topic_map = {}
    with open(input_summay_file, 'r') as f:
        topic_name = None
        topic_keywords = []
        for line in f.readlines():
            if line.strip() == '' or line.strip() == '\n':
                continue
            elif line.startswith('\t'):
                topic_keywords.append(line.strip().split('\t')[0])
            else:
                if topic_name is not None:
                    topic_map[topic_name] = {'topic': topic_name,
                        'keywords': list(topic_keywords),
                        'publication_counts': 0, 'publication_ids': []}
                topic_name = line.split('\t')[0].replace('/', ' ')
                topic_keywords = []
    if topic_name is not None:
        topic_map[topic_name] = {'topic': topic_name, 'keywords': list(
            topic_keywords), 'publication_counts': 0, 'publication_ids': []}
    for doc in src_coll.find():
        paper_id = doc['paper_id']
        for topic in doc['topics']:
            topic_name = topic['topic']
            topic_map[topic_name]['publication_counts'] += 1
            topic_map[topic_name]['publication_ids'].append(paper_id)
    dst_coll.drop()
    topic_id = 0
    for name in topic_map:
        topic = topic_map[name]
        topic['topic_id'] = topic_id
        topic_id += 1
        dst_coll.insert_one(topic)


def runner(src_coll=client.nasa_publication.LLDA_topics, dst_coll=client.
    nasa_publication.topic_overview):
    if len(sys.argv) < 2:
        helper()
        exit(1)
    summary(sys.argv[1], src_coll, dst_coll)


if __name__ == '__main__':
    runner()

from pymongo import MongoClient
import re, sys
client = MongoClient('hawking.sv.cmu.edu', 27019)


def helper():
    print('\n%s summary.txt\n\t\t' % sys.argv[0])


def summary(input_summay_file, src_coll, dst_coll):
    topic_map = {}
    with open(input_summay_file, 'r') as f:
        topic_name = None
        topic_keywords = []
        for line in f.readlines():
            if line.strip() == '' or line.strip() == '\n':
                continue
            elif line.startswith('\t'):
                topic_keywords.append(line.strip().split('\t')[0])
            else:
                if topic_name is not None:
                    topic_map[topic_name] = {'topic': topic_name,
                        'keywords': list(topic_keywords),
                        'publication_counts': 0, 'publication_ids': []}
                topic_name = line.split('\t')[0].replace('/', ' ')
                topic_keywords = []
    if topic_name is not None:
        topic_map[topic_name] = {'topic': topic_name, 'keywords': list(
            topic_keywords), 'publication_counts': 0, 'publication_ids': []}
    for doc in src_coll.find():
        paper_id = doc['paper_id']
        for topic in doc['topics']:
            topic_name = topic['topic']
            topic_map[topic_name]['publication_counts'] += 1
            topic_map[topic_name]['publication_ids'].append(paper_id)
    dst_coll.drop()
    topic_id = 0
    for name in topic_map:
        topic = topic_map[name]
        topic['topic_id'] = topic_id
        topic_id += 1
        dst_coll.insert_one(topic)


def runner(src_coll=client.nasa_publication.LLDA_topics, dst_coll=client.
    nasa_publication.topic_overview):
    if len(sys.argv) < 2:
        helper()
        exit(1)
    summary(sys.argv[1], src_coll, dst_coll)


if __name__ == '__main__':
    runner()

#!/usr/bin/python
# -*- coding: utf-8 -*-
from pymongo import MongoClient

import re, sys

client = MongoClient('hawking.sv.cmu.edu', 27019)



def helper():
	print('''
%s summary.txt
		''' % (sys.argv[0]))


def summary(input_summay_file, src_coll, dst_coll):
	topic_map = {}

	with open(input_summay_file, 'r') as f:
		topic_name = None
		topic_keywords = []
		for line in f.readlines():
			if line.strip() == '' or line.strip() == '\n':
				continue
			else:
				# print line
				if line.startswith('\t'):  # second hierarchical topic
					topic_keywords.append(line.strip().split("\t")[0])
					# print topic_keywords
				else: # first hierarchical topic 
					if topic_name is not None:
						topic_map[topic_name] = {'topic': topic_name, 'keywords': list(topic_keywords), 'publication_counts': 0, 'publication_ids':[]}
					topic_name = line.split("\t")[0].replace('/', ' ')
					topic_keywords = []
	if topic_name is not None:
		# print topic_name
		topic_map[topic_name] = {'topic': topic_name, 'keywords': list(topic_keywords), 'publication_counts': 0, 'publication_ids':[]}

	for doc in src_coll.find():
		paper_id = doc['paper_id']
		for topic in doc['topics']:
			topic_name = topic['topic']
			
			# print topic_name
			topic_map[topic_name]['publication_counts'] += 1
			topic_map[topic_name]['publication_ids'].append(paper_id)

	# print topic_map
	dst_coll.drop()
	topic_id = 0
	for name in topic_map:
		# print topic_map[name]
		topic = topic_map[name]
		topic['topic_id'] = topic_id
		topic_id += 1
		dst_coll.insert_one(topic)


def runner(src_coll=client.nasa_publication.LLDA_topics, dst_coll=client.nasa_publication.topic_overview):
	if len(sys.argv) < 2:
		helper()
		exit(1)
	
	summary(sys.argv[1], src_coll, dst_coll)

if __name__ == "__main__":
	runner()





