Ejemplo n.º 1
0
    if (stopwords_file.path_txt == None):
        pass
    else:
        print("Started parsing TXT with stopwords, wait for a while...")
        start_time = time()
        stopwords = split.get_list(stopwords_file.path_txt, enableComments = True)
        stopwords = set(stopwords)
        end_time = time()
        print("Parsing TXT with stopwords took {0:.3f}s".format(end_time - start_time), end = "\n\n")

    """
    Started getting keyword phrases from input_file
    """
    print("Started getting keyword phrases")
    start_time = time()
    keywords = keywords.getKeyPhrases(input_file.text, stopwords, lemmatizer = lemmatize)
    end_time = time()
    input_file.keywords = keywords
    if len(keywords) == 0:
        print("No keywords were found for an input file \"{0}\"".format(input_file.path_txt))
        exit(0)

    EXTRA_TIME += time()
    if (input("Do you want to print keyword phrases? (\"y\" or \"n\"): ") != "y"):
        pass
    else:
        print("Keyword phrases, generated by RAKE (with a phrase score):", end = "\n\n")
        for phrase in keywords:
            print("\"{0}\" ==> {1:.3f}".format(phrase[0], phrase[1]))
        print()
    EXTRA_TIME -= time()
Ejemplo n.º 2
0
#Getting words for deleting
if (stopwords_file == ''):
	stopwords = set()
	pass
else:
	#print("\nStarted parsing TXT with stopwords, wait for a while...")
	start_time = time()
	stopwords = split.get_list(stopwords_file, enableComments = True)
	end_time = time()
	print("\nParsing TXT with stopwords took {0:.3f}".format(end_time - start_time), "seconds")
	stopwords = set(stopwords)

print("\nStarted getting keyword phrases")
start_time = time()
keywords = keywords.getKeyPhrases(text, stopwords, lemmatizer = lemmatizer)
end_time = time()
print("Getting keyword phrases took {0:.3f}".format(end_time - start_time), "seconds")

if (output_file == ''):
	print("\nKeywords (generated by RAKE):\n")
	for key in keywords:
		print(key[0])
else:
	out = open(output_file, "w")
	for key in keywords:
		out.write("{0}\n".format(key[0]))
	out.close()

PROGRAM_END = time()
print("\nProgram ended successfully!\nExecution time {0:.3f} seconds".format(PROGRAM_END - PROGRAM_START))