Пример #1
0
def about_students():
    for class_room in school_data["classes"]:
        print("Ученики '%s' класса: " % class_room)
        for number, student in enumerate(search(students_data, class_room=class_room), start=1):
            # FIXME(Complete): учесть(во всей программе), в файле могут быть ученики из других школ
            print("     %s)%s" % (number, get_full_name(student)))
            # TODO(complete): Добавить нумерацию учеников для каждого класса
    print('Ожидают принятия в школу:')
    for number, student in enumerate(search(students_data, class_room='X'), start=1):
        print("     %s)%s" % (number, get_full_name(student)))
    print("-" * 24)
    input("Нажмите Enter для возврата в предыдущее меню\n:")
Пример #2
0
def about_classes():
    print("Все классы нашей школы")
    print("||", " || ".join(school_data['classes']), "||")
    print()
    class_room = input("Введите класс, для подробной информации по нему \n"
                           " или Enter для возврата в предыдущее меню:")
    if class_room in school_data["classes"]:
        print("\nИнформация по %s классу:" % class_room)
        print("     Учителя: ", [get_full_name(el) for el in search(teachers_data)])
        print("     Ученики: ", [get_full_name(el) for el in search(students_data)])
        input("Нажмите Enter для возврата в предыдущее меню")
    elif (class_room != '') and not (class_room in teachers_data['classes']):
        print('Введенного класса не существует')
        about_classes()
Пример #3
0
def about_students():
    for class_room in school_data["classes"]:
        print("Ученики '%s' класса: " % class_room)
        for number, student in enumerate(search(students_data,
                                                class_room=class_room),
                                         start=1):
            # FIXME(Complete): учесть(во всей программе), в файле могут быть ученики из других школ
            print("     %s)%s" % (number, get_full_name(student)))
            # TODO(complete): Добавить нумерацию учеников для каждого класса
    print('Ожидают принятия в школу:')
    for number, student in enumerate(search(students_data, class_room='X'),
                                     start=1):
        print("     %s)%s" % (number, get_full_name(student)))
    print("-" * 24)
    input("Нажмите Enter для возврата в предыдущее меню\n:")
Пример #4
0
def about_teachers():
    for class_room in school_data["classes"]:
        print("Учителя, преподающие в '%s' классе: " % class_room)
        for number, teacher in enumerate(search(teachers_data, class_room=class_room)):
            print("     %s)%s" % (number+1, get_full_name(teacher)))
        print("-" * 24)
    input("Нажмите Enter для возврата в предыдущее меню\n:")
Пример #5
0
def get_key_ideas(pos, lang, patterns_path):
    # load the patterns
    patterns = load_data(patterns_path)
    patterns = patterns["default_patterns_" + lang]
    # exceptions = patterns["default_exceptions_"+lang]

    # get the key ideas
    key_ideas = []

    tokens = [w[0] for w in pos]
    words = []
    for w in pos:
        if w[1][0] in ['J', 'V', 'N']:
            words.append(w[1][0])
        else:
            words.append(w[0])
    # patterns = [x[0] for x in self.patterns]

    for p in patterns:
        start = search(words, p)

        if start:
            key_idea = tokens[start:start + len(p)]
            key_ideas.append(key_idea)

    return key_ideas
Пример #6
0
def about_students():
    for class_room in school_data["classes"]:
        print("Ученики '%s' класса: " % class_room)
        for num, student in enumerate(search(students_data, class_room=class_room), start=1):
            # FIXME: учесть(во всей программе), в файле могут быть ученики из других школ
            print("     ", str(num) + ')', get_full_name(student))  # TODO: Добавить нумерацию учеников для каждого класса
        print("-" * 24)
    input("Нажмите Enter для возврата в предыдущее меню")
Пример #7
0
def about_teachers():
    for class_room in school_data["classes"]:
        print("Учителя, преподающие в '%s' классе: " % class_room)
        for number, teacher in enumerate(
                search(teachers_data, class_room=class_room)):
            print("     %s)%s" % (number + 1, get_full_name(teacher)))
        print("-" * 24)
    input("Нажмите Enter для возврата в предыдущее меню\n:")
Пример #8
0
def about_students():
    for class_room in school_data["classes"]:
        print("Ученики '%s' класса: " % class_room)
        for student in search(students_data, class_room=class_room):
            if student['school'] == "67 школа": #FIXME: в файле school.json тип школы на английском
                print("     ", enumerate(get_full_name(student), start=1))  # TODO: Добавить нумерацию учеников для каждого класса
        print("-" * 24)
    input("Нажмите Enter для возврата в предыдущее меню")
Пример #9
0
def make_group():
    tracks = []
    name = input("Queue Group Name: ")

    parser = SongParser("Song Parser")
    parser.add_argument('title', nargs="?")
    parser.add_argument('artist', nargs="?")
    parser.add_argument('-c', '--current', action='store_true')
    parser.add_argument('-u', '--uri')

    print("Input track name + artist or URI; type SAVE when finished!")
    adding = True

    while adding:
        candidate_track = input(f"Item {len(tracks) + 1}: ")
        if candidate_track.strip().upper() == 'SAVE':
            if len(tracks) > 0:
                with open(group_file) as gf:
                    try:
                        groups = json.load(gf)
                    except json.JSONDecodeError:
                        groups = {}

                groups[name] = tracks
                with open(group_file, 'w+') as gf:
                    json.dump(groups, gf)
            else:
                print("No tracks specified!")
            adding = False
        else:
            try:
                track = {}
                args = parser.parse_args(shlex.split(candidate_track))
                if args.title:
                    track = get_track(search(args.title, args.artist,
                                             spotify))[0]
                elif args.uri:
                    track = get_track(args.uri)[0]
                elif args.current:
                    track = get_track(current_uri())[0]
                else:
                    raise SongException(
                        "Invalid track specifier! Provide artist (and track), else specify current (-c) or uri (-u)!"
                    )

                if track:
                    confirm = input(
                        f"Found track: {track.get('name')} by {track.get('artist')}. Add to group {name} (y/n)? "
                    ).lower().strip()
                    if confirm == 'y': tracks.append(track)
                else:
                    print("Could not find a matching track!")

            except SongException as e:
                print(e)
Пример #10
0
def teachers():
    global teachers_data
    global school_data
    clear()
    print("*" * 24)
    print("* Welcome to %s %s *" % (school_data['number'], school_data['type']))
    print("*" * 24)
    print("     MENU > Информация > Об учителях")
    # TODO(complete): дописать вывод по аналогии с учениками
    for class_room in school_data["classes"]:
        print("Учителя '%s' класса: " % class_room)
        for num, teacher in enumerate(search(teachers_data, class_room=class_room)):
            print("     ", '%s)' % (num + 1), get_full_name(teacher))
            print("-" * 24)
    input("Нажмите Enter для возврата в предыдущее меню")
    return
Пример #11
0
def students():
    global students_data
    global school_data
    clear()
    print("*" * 24)
    print("* Welcome to %s %s *" % (school_data['number'], school_data['type']))
    print("*" * 24)
    print("     MENU > Информация > Об учениках")
    for class_room in school_data["classes"]:
        print("Ученики '%s' класса: " % class_room)
        for num, student in enumerate(search(students_data, class_room=class_room)):
            # FIXME(complete): учесть(во всей программе), в файле могут быть ученики из других школ
            # TODO(complete): Добавить нумерацию учеников для каждого класса
            print("     ", '%s)' % (num + 1), get_full_name(student))
            print("-" * 24)
    input("Нажмите Enter для возврата в предыдущее меню")
    return
Пример #12
0
	def search_account_codes(self):
		try :			
			data = utilities.search(ACCOUNT_CODES, SEARCH, self)
			utilities.log_req_res(data, self)
		except:
			utilities.get_error_message(self)
Пример #13
0
	def search_tax_codes(self):
		try :			
			data = utilities.search(TAX_CODES, SEARCH, self)
			utilities.log_req_res(data, self)
		except:
			utilities.get_error_message(self)
Пример #14
0
	def search_supplier_invoices(self):
		try :			
			data = utilities.search(SUPPLIER_INVOICES, SEARCH, self)
			utilities.log_req_res(data, self)
		except:
			utilities.get_error_message(self)
Пример #15
0
	def search_purchase_orders(self):
		try :			
			data = utilities.search(PURCHASE_ORDERS, SEARCH, self)
			utilities.log_req_res(data, self)
		except:
			utilities.get_error_message(self)
Пример #16
0
	def search_customer_invoices(self):
		try :			
			data = utilities.search(CUSTOMER_INVOICES, SEARCH, self)
			utilities.log_req_res(data, self)
		except:
			utilities.get_error_message(self)
def mobRandomTrue():
    return utilities.search(monstersAll)
Пример #18
0
    parser.add_argument('-u', '--uri')
    parser.add_argument('-q', '--queue')
    parser.add_argument('-d', '--delete', nargs='*', default='UNDEFINED')

    args = parser.parse_args()
    if sys.argv[1:]:
        if not any([args.start, args.end, args.queue
                    ]) and args.delete == "UNDEFINED":
            exit(
                "Must specify a track start (-s), end (-e), queue (-q), or delete (-d)"
            )
        else:
            track = None
            if args.current: track = get_track(current())
            elif args.title:
                track = get_track(search(args.title, args.artist, spotify))
            elif args.uri:
                track = get_track(args.uri)

            if args.delete != 'UNDEFINED':
                if len(args.delete) == 0:
                    uri = (track or {}).get('uri')
                    if not uri:
                        exit(
                            "One of: uri (-u), title (-t) + artist (-a), or current (-c) must be specified!"
                        )
                    else:
                        print(
                            f"{color('Deleting rule', Colors.RED)} for {color(track.get('name'), Colors.CYAN)} [{color(track.get('artist'), Colors.YELLOW)}]..."
                        )
                        update_rule(uri, None, track=track)
Пример #19
0
def main():
	print "Enter precision:",
	targetPrecision = float(raw_input())
	precision = -1.0

	print "Enter Query:",
	inputQuery = raw_input()
	qTerms = inputQuery.split()

	bingAccountKey = "QgPWn9g/wi5g0BrHFTheQNwEjD+/m98WcIi8ps2G6V8="

	while(precision < targetPrecision):

		#Print bing API key
		print "Client Key\t= " + bingAccountKey

		#Print query terms
		query = qTerms[0]
		for qTerm in xrange(len(qTerms) - 1):
			query += (" "+qTerms[qTerm + 1])

		print "Query\t\t= " + query
		query = query.replace(" ", "+")

		#Print precision
		print "Precision\t= " + str(targetPrecision)

		#Print URL
		url = "https://api.datamarket.azure.com/Bing/Search/Web?Query=%27" + query + "%27&$top=10&$format=json"
		print "URL: " + url

		#query the API and get docs
		documents = utilities.search(query, url, bingAccountKey)

		#show results and get feedback
		documents = utilities.getFeedback(documents)

		#show new results
		print "======================"
		print "FEEDBACK SUMMARY"
		print "Query " + query.replace("+", " ")

		#intermediate check 
		if utilities.checkTargetPrecision(documents, targetPrecision):
			break

		print "Indexing results..."

		dFrequency = defaultdict(list)
		for index in xrange(len(documents)):
			#initialize scores to 0
			documents[index]['score'] = defaultdict(int)

			#get rid of characters
			documents[index] = utilities.removeCharacters(documents[index])

			#terms from description and title of document
			terms = utilities.getTerms(documents[index])

			wCount = float(len(terms))

			for term in terms:
				documents[index]['score'][term] = documents[index]['score'][term] + 1/wCount

				if(len(dFrequency[term]) is 0):
						dFrequency[term] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

				dFrequency[term][index] = 1


		dFrequency = utilities.computeDocumentFrequency(dFrequency, len(documents))

		#use the document frequency to update the scores
		documents = utilities.documentFrequencyTermScore(documents, dFrequency)

		#we then create to dicts: one that is relevant and the other that is not
		dRelevant, dNRelevant = utilities.divideDictionary(documents)

		#run Rocchio Algorithm
		mDict = utilities.getMasterDictionary(dRelevant, dNRelevant, documents, qTerms)

		#get the two most important terms to add
		bestTerm1, bestTerm2 = utilities.getBestTerms(mDict, qTerms)

		print "Augmenting by "+ bestTerm1 + " " + bestTerm2

		if(bestTerm1 != " "):
			qTerms.append(bestTerm1)
			if(bestTerm2 != " "):
					qTerms.append(bestTerm2)
		else:
			print "No further augumentation!"
			break			

		def score(m): return mDict[m.lower()]	
		qTerms.sort(key=score, reverse=True)
Пример #20
0
    print("4. Назад")
    choice = input(':')
    if choice == '1':
        clear()
        print("*" * 24)
        print("* Welcome to %s %s *" % (school_data['number'], school_data['type']))
        print("*" * 24)
        print("     MENU > Информация > О классах")
        print("Все классы нашей школы")
        print("||", " || ".join(school_data['classes']), "||")
        print()
        class_room = input("Введите класс, для подробной информации по нему \n"
                           " (или Enter для возврата в предыдущее меню):")
        if class_room in school_data["classes"]:
            print("\nИнформация по %s классу:" % class_room)
            print("     Учителя: ", [get_full_name(el) for el in search(teachers_data)])
            print("     Ученики: ", [get_full_name(el) for el in search(students_data)])
            input("Нажмите Enter для возврата в предыдущее меню")
            print('1. Выйти')
            choice = input(': ')
            if choice == 1:
                print('Goodbye')
            # TODO*: Сделать возврат в предыдущее меню(во всех местах программы).
            # TODO:Выход из программы только по пункту "выйти"(+)
        else:
            print('Выбран несуществующий класс')


    elif choice == '2':
        clear()
        print("*" * 24)
Пример #21
0
from Bio import Entrez
import graph
import utilities

Entrez.email = '*****@*****.**'
Entrez.api_key = 'f513b4e2e1a0b578c9d3dd731e36f19f7f08'


def __init__(self, email):
    Entrez.email = '*****@*****.**'
    Entrez.api_key = 'f513b4e2e1a0b578c9d3dd731e36f19f7f08'


if __name__ == '__main__':
    results = utilities.search('etiology')
    id_list = results['IdList']
    papers = utilities.fetch_details(id_list)
    utilities.summary_details(id_list)
    utilities.systematicApproach(utilities.narrow_list)
    utilities.remove_supp_authors(utilities.m_lastAuthor,
                                  utilities.m_authorList)
    graph.makeGraph(utilities.authorDict)
    graph.nodeDegree(graph.g)
    graph.graphAnalysis(graph.g)
Пример #22
0
        else:
            print("Такого класса нет")
            input("Нажмите Enter для возврата в предыдущее меню")

            # TODO*: Сделать возврат в предыдущее меню(во всех местах программы).
            # TODO:Выход из программы только по пункту "выйти"

    elif choice == "2":
        clear()
        print("*" * 24)
        print("* Welcome to %s %s *" % (school_data["number"], school_data["type"]))
        print("*" * 24)
        print("     MENU > Информация > Об учениках")
        for class_room in school_data["classes"]:
            print("Ученики '%s' класса: " % class_room)
            for student in search(students_data, class_room=class_room):
                for num in enumerate(students_data):
                    # FIXME: учесть(во всей программе), в файле могут быть ученики из других школ
                    print(
                        "     ", int(num) + 1, ".", get_full_name(student)
                    )  # TODO: Добавить нумерацию учеников для каждого класса
            print("-" * 24)
        input("Нажмите Enter для возврата в предыдущее меню")
    elif choice == "3":
        clear()
        print("*" * 24)
        print("* Welcome to %s %s *" % (school_data["number"], school_data["type"]))
        print("*" * 24)
        print("     MENU > Информация > Об учителях")
        print(" ... ")
        # TODO: дописать вывод по аналогии с учениками
Пример #23
0
	def search_jobs(self):
		try :			
			data = utilities.search(JOBS, SEARCH, self)
			utilities.log_req_res(data, self)
		except:
			utilities.get_error_message(self)
Пример #24
0
	def search_contacts(self):
		try :			
			data = utilities.search(CONTACTS, SEARCH, self)
			utilities.log_req_res(data, self)
		except:
			utilities.get_error_message(self)
Пример #25
0
	def search_assets(self):
		try :			
			data = utilities.search(ASSETS, SEARCH, self)
			utilities.log_req_res(data, self)
		except:
			utilities.get_error_message(self)
Пример #26
0
def main():
    print "Enter precision:",
    targetPrecision = float(raw_input())
    precision = -1.0

    print "Enter Query:",
    inputQuery = raw_input()
    qTerms = inputQuery.split()

    bingAccountKey = "QgPWn9g/wi5g0BrHFTheQNwEjD+/m98WcIi8ps2G6V8="

    while (precision < targetPrecision):

        #Print bing API key
        print "Client Key\t= " + bingAccountKey

        #Print query terms
        query = qTerms[0]
        for qTerm in xrange(len(qTerms) - 1):
            query += (" " + qTerms[qTerm + 1])

        print "Query\t\t= " + query
        query = query.replace(" ", "+")

        #Print precision
        print "Precision\t= " + str(targetPrecision)

        #Print URL
        url = "https://api.datamarket.azure.com/Bing/Search/Web?Query=%27" + query + "%27&$top=10&$format=json"
        print "URL: " + url

        #query the API and get docs
        documents = utilities.search(query, url, bingAccountKey)

        #show results and get feedback
        documents = utilities.getFeedback(documents)

        #show new results
        print "======================"
        print "FEEDBACK SUMMARY"
        print "Query " + query.replace("+", " ")

        #intermediate check
        if utilities.checkTargetPrecision(documents, targetPrecision):
            break

        print "Indexing results..."

        dFrequency = defaultdict(list)
        for index in xrange(len(documents)):
            #initialize scores to 0
            documents[index]['score'] = defaultdict(int)

            #get rid of characters
            documents[index] = utilities.removeCharacters(documents[index])

            #terms from description and title of document
            terms = utilities.getTerms(documents[index])

            wCount = float(len(terms))

            for term in terms:
                documents[index]['score'][
                    term] = documents[index]['score'][term] + 1 / wCount

                if (len(dFrequency[term]) is 0):
                    dFrequency[term] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

                dFrequency[term][index] = 1

        dFrequency = utilities.computeDocumentFrequency(
            dFrequency, len(documents))

        #use the document frequency to update the scores
        documents = utilities.documentFrequencyTermScore(documents, dFrequency)

        #we then create to dicts: one that is relevant and the other that is not
        dRelevant, dNRelevant = utilities.divideDictionary(documents)

        #run Rocchio Algorithm
        mDict = utilities.getMasterDictionary(dRelevant, dNRelevant, documents,
                                              qTerms)

        #get the two most important terms to add
        bestTerm1, bestTerm2 = utilities.getBestTerms(mDict, qTerms)

        print "Augmenting by " + bestTerm1 + " " + bestTerm2

        if (bestTerm1 != " "):
            qTerms.append(bestTerm1)
            if (bestTerm2 != " "):
                qTerms.append(bestTerm2)
        else:
            print "No further augumentation!"
            break

        def score(m):
            return mDict[m.lower()]

        qTerms.sort(key=score, reverse=True)
Пример #27
0
	def search_opportunities(self):
		try :			
			data = utilities.search(OPPORTUNITIES, SEARCH, self)
			utilities.log_req_res(data, self)
		except:
			utilities.get_error_message(self)