Учитывая текст с косыми чертами definitive/deterministic arithmetic/calculation
, цель состоит в том, чтобы перечислить возможные комбинации слов, например, ожидаемый результат:
definitive arithmetic
deterministic arithmetic
definitive calculation
deterministic calculation
Другой пример, ввод voice/speech wave information processing method/technique
, ожидаемый результат:
voice wave information processing method
voice wave information processing technique
speech wave information processing method
speech wave information processing technique
И иногда есть скобки, ожидаемый результат будет перечислять выходы с и без терминов внутри скобки, например, ввод bactericidal/microbidical (nature/properties)
, ожидаемый вывод:
bactericidal
microbidical
bactericidal nature
bactericidal properties
microbidical nature
microbidical properties
У меня естьпробовал это, чтобы решить тексты с одной косой чертой, но это слишком хакерский, есть ли более простой способ?
for english in inputs:
if sum([1 for tok in english.split(' ') if '/' in tok]) == 1:
x = [1 if '/' in tok else 0 for tok in english.split(' ') ]
left = english.split(' ')[:x.index(1)]
word = english.split(' ')[x.index(1)].split('/')
right = english.split(' ')[x.index(1)+1:]
for tok in word:
print(' '.join([left + [tok] + right][0]))
Как мне также захватить случаи с более чем одной косой чертой?
Вот список возможных входных данных:
definitive/deterministic arithmetic/calculation
random/stochastic arithmetic/calculation
both ends/edges/terminals
to draw/attract/receive attention
strict/rigorous/exact solution
both ends/edges/terminals
easy to conduct/perform/carry out
easy to conduct/perform/carry out
between/among (equals/fellows)
reference/standard/nominal value
one kind/type/variety/species
primary cause/source/origin
to be disordered/disturbed/chaotic
same category/class/rank
while keeping/preserving/maintaining/holding
driving/operating in the reverse/opposite direction
only/just that portion/much
cannot doubt/question/suspect
does not reach/attain/match
tube/pipe/duct axis
recatangular/Cartesian/orthogonal coordinates
tube/pipe/duct wall
acoustic duct/conduit/channel
site of damage/failure/fault
voice/speech wave information processing method/technique
fundamental/basic theorem/proposition
single/individual item/product
one body/unit/entity
first stage/grade/step
time/era of great leaps/strides
one form/shape/figure
reserve/spare circuit/line
basic/base/backing material
set/collection/group of tables
in the form of a thin sheet/laminate/veneer
minute/microscopic pore/gap
forming/molding and working/machining
small amount/quantity/dose
liquid crystal form/state/shape
to rub/grind/chafe the surface
the phenomenon of fracture/failure/collapse
compound/composite/combined effect
molecular form/shape/structure
…st/…nd/….rd/…th group (periodic table)
the architectural/construction world/realm
to seal/consolidate a material by firing/baking
large block/clump/clod
bruned/baked/fired brick
unbruned/unbaked/unfired brick
kiln/furnance/oven surface
stationary/stator vane/blade
moving/rotor vane/blade
industrial kiln/furnance/oven
mean/average pore size/diameter
hardened/cured/set material
kiln/oven/furnance lining
piping (layout/arrangement/system)
metallic luster/brilliance/shine
mechanical treatment/working/processing
thin-sheet/laminate/veneer manufacture
thin sheet/laminate/veneer
vehicle (cars/trucks/trains) field
sheet/panel/plate thickness
corrosion prevention/resistance/protection
wriggling/squirming/slithering motion
method for forming/molding/shaping
object to be molded/formed/shaped
pressurized molding/forming/shaping equipment
premolded/preformed object/body
to seal/consolidate a material by firing/baking
furnance/kiln/oven wall
slipping/sliding/gliding mode
bactericidal/microbidical (nature/properties)
secondary/rechargeable cell/battery
new region/domain/area