-
-
Save crosstyan/1fbbd4c3a3fe7ff8fc2a86a54fd1bcb7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import math | |
import click | |
def emphasize(word: str, strength: float) -> tuple[str, float]: | |
""" | |
The weight of AI focus will be multiplied by 1.05 if you enclose the tags or | |
text you want the AI to focus on more with { and } | |
e.g. | |
{word} = 1.05 | |
{{word}} = (1.05)^2 | |
{{{word}}} = (1.05)^3 | |
The weight of AI focus will be divided by 1.05 (multiply with 0.95238) | |
if you enclose the tags or text you want the AI to focus on less with [ and ]. | |
e.g. | |
[word] = 0.95238 | |
[[word]] = (0.95238)^2 | |
[[[word]]] = (0.95238)^3 | |
""" | |
if strength == 1.0: | |
return (word, strength) | |
if strength > 1.0: | |
brackets = math.ceil(math.log(strength, 1.05)) | |
return ("{" * brackets + word + "}" * brackets, 1.05 ** brackets) | |
if strength < 1.0: | |
brackets = math.ceil(math.log(strength, 0.95238)) | |
return ("[" * brackets + word + "]" * brackets, 0.95238 ** brackets) | |
@click.command() | |
@click.argument("text", type=str) | |
@click.argument("strength", type=float) | |
def main(text:str, strength:float): | |
t, s = emphasize(text, strength) | |
print(t) | |
print(s) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment