-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
c9f9cd1
commit fe43e68
Showing
5 changed files
with
203 additions
and
0 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 @@ | ||
/src/gen/ |
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
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,129 @@ | ||
{ | ||
"name": "Similarity", | ||
"parameters": [ | ||
{ | ||
"name": "granularity", | ||
"type": "boolean" | ||
}, | ||
{ | ||
"name": "size", | ||
"type": "int" | ||
} | ||
], | ||
"workers": [ | ||
{ | ||
"name": "tokenizerA", | ||
"type": "Tokenizer", | ||
"arguments": [ | ||
"granularity" | ||
] | ||
}, | ||
{ | ||
"name": "shinglerA", | ||
"type": "Shingler", | ||
"arguments": [ | ||
"size" | ||
] | ||
}, | ||
{ | ||
"name": "tokenizerB", | ||
"type": "Tokenizer", | ||
"arguments": [ | ||
"granularity" | ||
] | ||
}, | ||
{ | ||
"name": "shinglerB", | ||
"type": "Shingler", | ||
"arguments": [ | ||
"size" | ||
] | ||
}, | ||
{ | ||
"name": "vectorAA", | ||
"type": "VectorMultiplier" | ||
}, | ||
{ | ||
"name": "vectorAB", | ||
"type": "VectorMultiplier" | ||
}, | ||
{ | ||
"name": "vectorBB", | ||
"type": "VectorMultiplier" | ||
}, | ||
{ | ||
"name": "cosine", | ||
"type": "CosineSimilarity" | ||
} | ||
], | ||
"channels": [ | ||
{ | ||
"fromWorker": "tokenizerA", | ||
"toWorker": "shinglerA", | ||
"toPin": "input" | ||
}, | ||
{ | ||
"fromWorker": "tokenizerB", | ||
"toWorker": "shinglerB", | ||
"toPin": "input" | ||
}, | ||
{ | ||
"fromWorker": "shinglerA", | ||
"toWorker": "vectorAA", | ||
"toPin": "a" | ||
}, | ||
{ | ||
"fromWorker": "shinglerA", | ||
"toWorker": "vectorAA", | ||
"toPin": "b" | ||
}, | ||
{ | ||
"fromWorker": "shinglerA", | ||
"toWorker": "vectorAB", | ||
"toPin": "a" | ||
}, | ||
{ | ||
"fromWorker": "shinglerB", | ||
"toWorker": "vectorAB", | ||
"toPin": "b" | ||
}, | ||
{ | ||
"fromWorker": "shinglerB", | ||
"toWorker": "vectorBB", | ||
"toPin": "a" | ||
}, | ||
{ | ||
"fromWorker": "shinglerB", | ||
"toWorker": "vectorBB", | ||
"toPin": "b" | ||
}, | ||
{ | ||
"fromWorker": "vectorAA", | ||
"toWorker": "cosine", | ||
"toPin": "aa" | ||
}, | ||
{ | ||
"fromWorker": "vectorAB", | ||
"toWorker": "cosine", | ||
"toPin": "ab" | ||
}, | ||
{ | ||
"fromWorker": "vectorBB", | ||
"toWorker": "cosine", | ||
"toPin": "bb" | ||
} | ||
], | ||
"inPins": [ | ||
{ | ||
"worker": "tokenizerA", | ||
"pin": "input" | ||
}, | ||
{ | ||
"worker": "tokenizerB", | ||
"pin": "input" | ||
} | ||
], | ||
"outPin": { | ||
"worker": "cosine" | ||
} | ||
} |
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 @@ | ||
// TODO: create Workflow template! |
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,27 @@ | ||
import argparse | ||
import jinja2 | ||
import json | ||
from pathlib import Path | ||
|
||
parser = argparse.ArgumentParser(description='Generate Java file from template using a JSON model.') | ||
parser.add_argument('input_model', type=str, help='Path to the input JSON model file.') | ||
parser.add_argument('template_file', type=str, help='Path to the template file.') | ||
parser.add_argument('output_file', type=str, help='Path to the output Java file.') | ||
|
||
args = parser.parse_args() | ||
|
||
output_file = Path(args.output_file) | ||
output_file.parent.mkdir(exist_ok=True, parents=True) | ||
|
||
with open(args.input_model, 'r') as file: | ||
model = json.load(file) | ||
|
||
for in_pin in model['inPins']: | ||
in_pin['name'] = f"{in_pin['worker']}{in_pin['pin'].capitalize()}" | ||
for channel in model['channels']: | ||
channel['name'] = f"{channel['fromWorker']}_{channel['toWorker']}_{channel['toPin']}" | ||
|
||
template_loader = jinja2.FileSystemLoader(searchpath="./") | ||
template_env = jinja2.Environment(loader=template_loader) | ||
template = template_env.get_template(args.template_file) | ||
template.stream(model).dump(args.output_file) |