-
Notifications
You must be signed in to change notification settings - Fork 24
Annotator split #333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
SvenjaKern
wants to merge
4
commits into
main
Choose a base branch
from
annotator_split
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Annotator split #333
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The module gives out a random number within a given frame. With that, you can split annotations randomly. Every split between 0 and the maximal lenght of the frame is possible. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from pydantic import BaseModel | ||
import random | ||
|
||
INPUT_EXAMPLE = { | ||
"number": 4 | ||
} | ||
|
||
|
||
class AnnotationSplitModel(BaseModel): | ||
number: int | ||
|
||
class Config: | ||
schema_example = {"example": INPUT_EXAMPLE} | ||
|
||
def annotator_split(request: AnnotationSplitModel): | ||
"""Generates a random number for split annotations""" | ||
number = request.number | ||
return random.randint(0, number-1) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
```python | ||
import random | ||
|
||
def annotator_split(record) -> int: | ||
return random.randint(0, record-1) | ||
|
||
# ↑ necessary bricks function | ||
# ----------------------------------------------------------------------------------------- | ||
# ↓ example implementation | ||
|
||
def example_integration(): | ||
max_number = [2, 4, 6, 8, 10] | ||
for number in max_number: | ||
print(f"the random number in the maximal number-range of {number} is {annotator_split(number)}") | ||
|
||
example_integration() | ||
``` |
14 changes: 14 additions & 0 deletions
14
generators/numbers/annotator_split/code_snippet_refinery.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
```python | ||
import random | ||
|
||
ATTRIBUTE: int | ||
|
||
def annotator_split(record): | ||
try: | ||
return random.randint(0, record[ATTRIBUTE]-1) | ||
except: | ||
print("Something went wrong. Please make sure, your desired maximal number is an Integer and bigger than 0.") | ||
|
||
|
||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from util.configs import build_generator_function_config | ||
from util.enums import State, RefineryDataType, BricksVariableType, SelectionType | ||
from . import annotator_split, INPUT_EXAMPLE | ||
|
||
|
||
def get_config(): | ||
return build_generator_function_config( | ||
function=annotator_split, | ||
input_example=INPUT_EXAMPLE, | ||
issue_id=240, | ||
tabler_icon="Dice-3", | ||
min_refinery_version="1.7.0", | ||
state=State.PUBLIC.value, | ||
type="python_function", | ||
kern_token_proxy_usable="false", | ||
docker_image="none", | ||
available_for=["refinery", "common"], | ||
part_of_group=[ | ||
"numbers", | ||
], # first entry should be parent directory | ||
# bricks integrator information | ||
integrator_inputs={ | ||
"name": "annotator_split", | ||
"refineryDataType": RefineryDataType.INTEGER.value, | ||
"variables": { | ||
"N_SPLIT": { | ||
"selectionType": SelectionType.CHOICE.value, | ||
"description": "only text fields", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This brick doesn't require input. |
||
"addInfo": [ | ||
BricksVariableType.ATTRIBUTE.value, | ||
BricksVariableType.GENERIC_STRING.value, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this correct? |
||
], | ||
}, | ||
}, | ||
}, | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.