-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* LangChain based matching * Basic boolean output parser * CLI for experimenting * Hard coded prompt
- Loading branch information
Showing
17 changed files
with
1,768 additions
and
7 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,106 @@ | ||
name: FRP-cli | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- 'packages/frp-cli/**' | ||
branches: | ||
- main | ||
tags: | ||
- "v*.*.*" | ||
pull_request: | ||
paths: | ||
- 'packages/frp-cli/**' | ||
branches: | ||
- main | ||
|
||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
name: Check for Linting Errors | ||
defaults: | ||
run: | ||
working-directory: packages/frp-cli | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry | ||
poetry install --with dev | ||
- name: Lint | ||
run: poetry run flake8 | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
name: Build | ||
defaults: | ||
run: | ||
working-directory: packages/frp-cli | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry | ||
cd ../frp | ||
poetry install | ||
cd ../frp-cli | ||
poetry install --with dev | ||
- name: Build | ||
run: poetry build | ||
|
||
type-checking: | ||
runs-on: ubuntu-latest | ||
name: Run Type Checking | ||
defaults: | ||
run: | ||
working-directory: packages/frp-cli | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry | ||
cd ../frp | ||
poetry config virtualenvs.create false | ||
poetry install | ||
cd ../frp-cli | ||
poetry install --with dev | ||
- name: Type Checking | ||
run: poetry run mypy frp_cli/ |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
venv/ | ||
__pycache__/ |
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,3 @@ | ||
[flake8] | ||
max-line-length = 160 | ||
per-file-ignores = __init__.py:F401 |
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,3 @@ | ||
dist/ | ||
*.pyc | ||
data/ |
Empty file.
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 @@ | ||
from frp_cli.main import main |
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,68 @@ | ||
from argparse import ArgumentParser, BooleanOptionalAction | ||
from pathlib import Path | ||
from frp import FRPScholarlyAnalysis, Matcher | ||
|
||
|
||
def scholarly_analysis(input_csv: Path, frp_title: str, frp_year: int, save_results: bool, save_output: Path) -> None: | ||
if not input_csv.exists(): | ||
print('File {} does not exist'.format(input_csv)) | ||
exit(1) | ||
|
||
# Make the matcher | ||
matcher = Matcher() | ||
|
||
# Run the analysis | ||
analyzer = FRPScholarlyAnalysis(matcher) | ||
|
||
# Collect the results | ||
results = analyzer.run_frp_analysis(input_csv, frp_title, frp_year) | ||
|
||
# If the user wants the data saved, save it to the output location | ||
if save_results: | ||
results.to_csv(save_output) | ||
|
||
print(results['Part of FRP']) | ||
|
||
|
||
def main(): | ||
parser = ArgumentParser() | ||
|
||
# Sub parser for the different commands | ||
sub_parser = parser.add_subparsers(dest='command', required=True) | ||
|
||
# Command: scholarly | ||
scholarly_parser = sub_parser.add_parser('scholarly') | ||
scholarly_parser.add_argument('--input', | ||
required=True, | ||
help='Input CSV') | ||
scholarly_parser.add_argument('--frp-title', | ||
required=False, | ||
default='Leveraging AI to Examine Disparities and Bias in Health Care', | ||
help='Name of the FRP to run matching against') | ||
scholarly_parser.add_argument('--frp-year', | ||
required=False, | ||
default=2022, | ||
type=int, | ||
help='Year to start (inclusive) considering articles') | ||
scholarly_parser.add_argument('--save-output', | ||
required=False, | ||
default=False, | ||
action=BooleanOptionalAction, | ||
help='Flag if the results of the matching should be stored') | ||
scholarly_parser.add_argument('--output-csv', | ||
required=False, | ||
default='data/scholarly_matching_results.csv', | ||
help='Where to store the results of the matching') | ||
|
||
args = parser.parse_args() | ||
|
||
# Determine the correct command to run | ||
if args.command == 'scholarly': | ||
scholarly_analysis(Path(args.input), args.frp_title, args.frp_year, args.save_output, Path(args.output_csv)) | ||
return | ||
else: | ||
print('Command {} not recognized'.format(args.command)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.