Implemented recommend
This commit is contained in:
@@ -14,7 +14,7 @@ from .util import ffmpeg_description, parse_ucs
|
|||||||
|
|
||||||
|
|
||||||
def recommend_text(text: str, ctx: InferenceContext):
|
def recommend_text(text: str, ctx: InferenceContext):
|
||||||
return None
|
return ctx.classify_text_ranked(text)
|
||||||
|
|
||||||
@click.group(epilog="For more information see "
|
@click.group(epilog="For more information see "
|
||||||
"<https://git.squad51.us/jamie/ucsinfer>")
|
"<https://git.squad51.us/jamie/ucsinfer>")
|
||||||
@@ -22,16 +22,15 @@ def recommend_text(text: str, ctx: InferenceContext):
|
|||||||
def ucsinfer():
|
def ucsinfer():
|
||||||
"""
|
"""
|
||||||
Tools for applying UCS categories to sounds using large-language Models
|
Tools for applying UCS categories to sounds using large-language Models
|
||||||
|
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ucsinfer.command('recommend')
|
@ucsinfer.command('recommend')
|
||||||
@click.option('--text', type=Optional[str], default=None,
|
@click.option('--text', default=None,
|
||||||
help="Recommend a category for given text instead of reading "
|
help="Recommend a category for given text instead of reading "
|
||||||
"from a file")
|
"from a file")
|
||||||
@click.argument('files', nargs=-1)
|
@click.argument('paths', nargs=-1)
|
||||||
@click.option('--model', type=str, metavar="<model-name>",
|
@click.option('--model', type=str, metavar="<model-name>",
|
||||||
default="paraphrase-multilingual-mpnet-base-v2",
|
default="paraphrase-multilingual-mpnet-base-v2",
|
||||||
show_default=True,
|
show_default=True,
|
||||||
@@ -66,6 +65,16 @@ def recommend(text, paths, model):
|
|||||||
"recommendations":None
|
"recommendations":None
|
||||||
})
|
})
|
||||||
|
|
||||||
|
for rec in recommendations:
|
||||||
|
print("----------")
|
||||||
|
if 'path' in rec:
|
||||||
|
print(f"Path: {rec['path']}")
|
||||||
|
|
||||||
|
print(f"Text: {rec['text'] or '<None>'}")
|
||||||
|
if rec['recommendations']:
|
||||||
|
for r in rec['recommendations']:
|
||||||
|
cat, subcat, _ = ctx.lookup_category(r)
|
||||||
|
print(f"- {r}: {cat}-{subcat}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user