-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,187 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
|
||
**Smartphone (please complete the following information):** | ||
- Device: [e.g. iPhone6] | ||
- OS: [e.g. iOS8.1] | ||
- Browser [e.g. stock browser, safari] | ||
- Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
name: Custom issue template | ||
about: Describe this issue template's purpose here. | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,5 +103,4 @@ def find_sections(): | |
return 'OK' | ||
|
||
if __name__ == '__main__': | ||
app.run(debug=True) | ||
|
||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
from flask import Flask, request | ||
from docx import Document | ||
from pathlib import Path | ||
import sys | ||
|
||
#@app.route('/find-sections', methods=['POST']) | ||
def find_sections(): | ||
# Check for missing request data | ||
""" | ||
if 'file_path' not in request.json: | ||
return 'Missing file_path field', 400 | ||
if 'search_terms' not in request.json: | ||
return 'Missing search_terms field', 400 | ||
if 'sections' not in request.json: | ||
return 'Missing sections field', 400 | ||
if 'specifyLines' not in request.json: | ||
return 'Missing specifyLines field', 400 | ||
if 'use_total_lines' not in request.json: | ||
return 'Missing use_total_lines field', 400 | ||
if 'lines' not in request.json: | ||
return 'Missing lines field', 400 | ||
""" | ||
|
||
# Get the file path from the request | ||
|
||
file_path = sys.argv[1] | ||
tempSearch_terms = sys.argv[2] | ||
tempSections = sys.argv[3] | ||
tempSpecifyLines = sys.argv[4] | ||
tempUse_total_lines = sys.argv[5] | ||
tempTotal_lines = sys.argv[6] | ||
|
||
|
||
search_terms = [tempSearch_terms] | ||
use_total_lines = bool(tempUse_total_lines) | ||
total_lines = int(tempTotal_lines) | ||
|
||
tempSections = list(tempSections) | ||
sections = [int(val) for val in tempSections] | ||
|
||
specifyLines = [] | ||
num = 0 | ||
while num <= len(sections): | ||
specifyLines.append(tempSpecifyLines) | ||
num += num + 1 | ||
|
||
|
||
"""file_path = request.json['file_path']""" | ||
|
||
# Read the file | ||
with open(file_path, 'r') as f: | ||
Lines = f.readlines() | ||
|
||
# Get the search terms, sections, and lines from the request | ||
""" | ||
search_terms = request.json['search_terms'] | ||
sections = request.json['sections'] | ||
specifyLines = request.json['specifyLines'] | ||
use_total_lines = request.json['use_total_lines'] | ||
total_lines = request.json['lines'] | ||
""" | ||
|
||
# Create a new document | ||
document = Document() | ||
|
||
# Iterate over the search terms and find the corresponding sections | ||
for term in search_terms: | ||
lineNo = 0 | ||
termLineNo = [] | ||
termsNum = 0 | ||
for line in Lines: | ||
if term in line: | ||
termLineNo.append(lineNo) | ||
termsNum += 1 | ||
#print(termsNum, term) | ||
lineNo += 1 | ||
|
||
|
||
|
||
# Add the sections to the document | ||
|
||
|
||
for i in sections: | ||
section_lines = specifyLines[i-1].split() | ||
start_line = termLineNo[i-1] | ||
line_empty = 0 | ||
|
||
if section_lines[0] == 'WHOLE' and use_total_lines == False: | ||
while line_empty == 0: | ||
if Lines[start_line] != "\n": | ||
section = document.add_paragraph(Lines[start_line]) | ||
start_line += 1 | ||
else: | ||
line_empty = 1 | ||
|
||
if section_lines[0] == 'WHOLE' and use_total_lines == True: | ||
for _ in range(total_lines - start_line + termLineNo[i-1]): | ||
section = document.add_paragraph(Lines[start_line]) | ||
start_line += 1 | ||
line_empty = 1 | ||
else: | ||
start_line += 1 | ||
line_empty = 1 | ||
|
||
elif section_lines[0] == 'FIRST': | ||
line_count = -1 | ||
while line_count < int(section_lines[1]): | ||
section = document.add_paragraph(Lines[start_line]) | ||
start_line += 1 | ||
line_count += 1 | ||
|
||
elif section_lines[0] == 'LAST': | ||
line_count = -1 | ||
document.add_paragraph(Lines[start_line]) | ||
document.add_paragraph(Lines[start_line + 1]) | ||
while line_count < int(section_lines[1]): | ||
section = document.add_paragraph(Lines[start_line+10]) | ||
start_line += 1 | ||
line_count += 1 | ||
|
||
elif section_lines[0] == 'SPECIFIC': | ||
specific_lines = [int(l) for l in section_lines[1].split(",")] | ||
document.add_paragraph(Lines[start_line]) | ||
for l in specific_lines: | ||
section = document.add_paragraph(Lines[start_line + l + 1]) | ||
|
||
|
||
|
||
|
||
try: | ||
# Save the document | ||
final_location = Path("../../../esp/outputData/data_conversion.docx") | ||
final_location = final_location.resolve() | ||
document.save(final_location) | ||
except Exception as e: | ||
return f'Error saving document: {e}', 500 | ||
|
||
return 'OK' | ||
|
||
|
||
|
||
""" | ||
if __name__ == '__main__': | ||
app.run(debug=True) | ||
""" | ||
|
||
|
||
result = find_sections() | ||
print(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
In regards to the arguments, reference the sample line below: | ||
|
||
python APIusingCMD.py "C:\Users\seala\csci4961\ORCAdata\Styrene-bd2.txt" "CARTESIAN COORDINATES (ANGSTROEM)" 123 "FIRST 6" True 2000 | ||
|
||
To start, you must call python APIusingCMD.py. The remaining arguments represent each component one needs to generate | ||
the output file. | ||
|
||
Arguments: | ||
|
||
0 - name of python file (APIusingCMD.py) | ||
1 - The dir of the input file location | ||
2 - The key terms one desires **note: key terms must be in all caps and within quotes (""), this argument is sensitive to caps and spaces. | ||
3 - The list of sections, pass this as a string with no spaces (i.e. 123 will turn into a list [1,2,3] of ints | ||
4 - represents the specify lines element, This must be a string, such as "WHOLE", "FIRST", "LAST" or "SPECIFIC", where for first and last, you must specify a number. for instance, "FIRST 6" (**note the space and the use of all caps) stands for the first six lines of that section. | ||
5 - A bool value to use the total lines passed in the last argument or not. Pass this as a string either True or False. | ||
6 - total number of lines for the output doc. pass this as a string such as 2000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* The code in this folder is the code for the prototype view of the home page. This was created on February 12th, | ||
2023. To get this view working, simply take the .ts, .css, and .html files in this folder and use them to replace | ||
the files located in the \frontend dashboard folder. The path below is an example of one of the files you would want | ||
to replace to get this code working. Note that you must safely store the files stored in \frontend elsewhere while | ||
using these files located in prototype. | ||
|
||
...\esp\frontend\orca_data_converter\src\app\views\dashboard\dashboard.component.ts | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
:host ::ng-deep .custom-ms | ||
.p-multiselect-label { | ||
width: 300px !important; | ||
} | ||
|
||
#whole { | ||
font-family: 'Calibri'; | ||
font-size: 20px; | ||
text-align: center; | ||
padding: 80px 0; | ||
} | ||
|
||
#customFile { | ||
display: none; | ||
} | ||
|
||
.form-label { | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
display: inline-block; | ||
padding: 8px 15px; | ||
cursor: pointer; | ||
font-size: 18px; | ||
transition-duration: 0.7s; | ||
} | ||
|
||
.form-label:hover { | ||
background-color: black; | ||
color:white; | ||
} | ||
|
||
#keyTerms-toSearch { | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
padding: 8px 12px; | ||
width: 210x; | ||
box-sizing: border-box; | ||
font-size: 18px; | ||
} | ||
|
||
|
||
#fileNameInput { | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
padding: 8px 12px; | ||
width: 210x; | ||
box-sizing: border-box; | ||
font-size: 18px; | ||
} | ||
|
||
#fileNameInput:focus { | ||
border: 2px solid #555; | ||
} | ||
|
||
#downloadButton { | ||
font-family: 'Calibri'; | ||
font-size: 18px; | ||
color: black; | ||
background-color: white; | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
margin-top: 25px; | ||
padding: 20px; | ||
transition-duration: 0.7s; | ||
cursor: pointer; | ||
} | ||
|
||
#downloadButton:hover { | ||
background-color: black; | ||
color:white; | ||
} |
Oops, something went wrong.