forked from LechMadeyski/AutomatedSearchHelper
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
61 lines (61 loc) · 2.55 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# import logging
# import json
#
# from TextSearchEngine.search_functions import *
# from ArticlesDataDownloader.ArticlesDataDownloader import ArticlesDataDownloader
# from AutomatedSearchHelperUtilities.getDoiFilename import getDoiFilename
# from SearchResultHtmlDisplay.findingsToHtml import findingsToHtml
# import AutomatedSearchHelperUtilities.configuration as configuration
# from AutomatedSearchHelperUtilities.utilities import createDirectoryIfNotExists
#
# def logSearchResults(articleText, searchResult):
# for resultSection in searchResult:
# logging.info("Something found in section "+ articleText["text"][resultSection["sectionIndex"]]["title"] )
# for paragraph in resultSection["paragraphs"]:
# parIndex = paragraph["paragraphIndex"]
# for sentence in paragraph["sentences"]:
# sentIndex = sentence["sentenceIndex"]
# fullSentence = articleText["text"][resultSection["sectionIndex"]]["paragraphs"][parIndex]["sentences"][sentIndex]
#
# for finding in reversed(sentence["findings"]):
# fullSentence = fullSentence[:finding[0]] + "!!!<" + fullSentence[finding[0]:finding[1]] + ">!!!"+ fullSentence[finding[1]:]
# logging.info(fullSentence)
#
#
# def main():
# configuration.configureLogger()
# directoryForAritclesTexts = 'outputArticles'
# createDirectoryIfNotExists(directoryForAritclesTexts)
#
# downloader = ArticlesDataDownloader(directoryForAritclesTexts)
#
# directoryForFindResults = 'outputFinder'
# createDirectoryIfNotExists(directoryForFindResults)
#
# outputHtmlFolder = 'outputHtmls'
# createDirectoryIfNotExists(outputHtmlFolder)
#
# resultFiles = downloader.getDownloadArticles()
#
# finder = EXACT_WORD("C", case_sensitive= True)
#
# for filename in resultFiles:
# searchResult = None
# logging.info("Running finder for "+ filename)
# with open(filename, 'r') as f:
# articleText = json.load(f)
# searchResult = finder(articleText)
#
# if searchResult is not None:
# logging.info("Found something for doi "+ articleText["doi"] + ": " + str(searchResult))
# with open(getDoiFilename(directoryForFindResults, articleText["doi"]), 'w', encoding='utf-8') as f:
# f.write(json.dumps(searchResult))
#
# with open(getDoiFilename(outputHtmlFolder, articleText["doi"], "html"), 'w', encoding='utf-8') as f:
# f.write(findingsToHtml(articleText, searchResult))
#
# #logSearchResults(articleText, searchResult)
#
#
# if __name__ == '__main__':
# main()