Class: Synthra::Types::TextContent::IndicesPair
- Defined in:
- lib/synthra/types/text_content/text_generation.rb
Overview
Indices pair for entity positions
Generates [start, end] pairs for text entity positions.
Instance Method Summary collapse
- #generate_edge(rng, context, args) ⇒ Object
- #generate_invalid(rng, context, args) ⇒ Object
- #generate_random(rng, context, args) ⇒ Object
Instance Method Details
#generate_edge(rng, context, args) ⇒ Object
511 512 513 514 515 516 517 518 |
# File 'lib/synthra/types/text_content/text_generation.rb', line 511 def generate_edge(rng, context, args) rng.sample([ [0, 0], # Zero length [0, 1], # Single char [0, 280], # Full tweet length [100, 105] # End of text ]) end |
#generate_invalid(rng, context, args) ⇒ Object
520 521 522 523 524 525 526 527 528 |
# File 'lib/synthra/types/text_content/text_generation.rb', line 520 def generate_invalid(rng, context, args) rng.sample([ nil, [], [10, 5], # End before start [-1, 10], # Negative start "invalid" ]) end |
#generate_random(rng, context, args) ⇒ Object
505 506 507 508 509 |
# File 'lib/synthra/types/text_content/text_generation.rb', line 505 def generate_random(rng, context, args) start = rng.int(0, 100) length = rng.int(5, 30) [start, start + length] end |