Country name mashup generator
Jelly, 74 73 bytes
JṖXṬk⁸ḢḢFṪ;ƲƭF)jṪḢƭ€Ṁ$$
ḢṖ;
ṪḢṪ;Ɗṭ
Fe€ØcṖTXṬkḢḢṪƭ)
e€⁾ -k)ẈỊḄ‘ƲĿ
Ḣ,2KƊÇE?
Try it online!
A full program that takes a list of two strings as its argument and implicitly outputs the mashed up country name.
The handling of hyphens is relatively costly, particularly since they are included whichever side of the split they fall.
Explanation
Helper link 1
Handles case where both countries have multiple words
) | For each country:
J | - Sequence along words
Ṗ | - Remove last
X | - Pick one at random
Ṭ | - Convert to a boolean list with a 1 at that index
k⁸ | - Split list of words after that point
ƭ | - Alternate between:
Ḣ | - Head (first set of words for the first country)
Ʋ | - Following as a monad (for the second country)
Ḣ | - Head (first set of words, also removed from the country)
F | - Flatten
Ṫ | - Tail (i.e. last character which will be space or hyphen)
; | - Concatenate to remaining words for second country
F | - Flatten
$ | Following as a monad
j $ | - Join countries with following as a monad
ṪḢƭ€ | - Alternate between tail for first country and head for second
Ṁ | - Max (will be hyphen if one present, otherwise space)
Helper link 2
Handles case where only first country has multiple words
Ḣ | Head (first country)
Ṗ | Remove last word
; | Concatenate to second country
Helper link 3
Handles case where only second country has multiple words
Ṫ | Tail (second country)
Ɗ | Following as a monad:
Ḣ | - Head (first word; note this will also be removed from the first country)
Ṫ | - Tail (last character)
; | - Concatenated to remaining words
ṭ | Tag onto the end of the first country
Helper link 4
Handles case where both countries have single words
) | For each country
F | - Flatten (remove the layer of lists generated in helper link 5)
eۯc | - Check whether each character is a vowel
Ṗ | - Remove last
T | - Comvert to list of indices
X | - Pick one at random
Ṭ | - Convert to a boolean list with a 1 at that index
kḢ | - Split the original country name after that vowel
ḢṪƭ | - Alternate between taking the head (for first country) and tail (for second)
Helper link 5
Splits each country into words and dispatched to helper links 1-4 depending on which countries have multiple words
) | For each country:
e€⁾ - | - Check whether each character is a space or hyphen
k | - Split country after those characters
ƲĿ | Call the link indicated by the number calculated by the following monad:
Ẉ | Lengths of lists (i.e. number of words in each country)
Ị | Insignificant (abs(x)<=1)
Ḅ | Convert from binary
‘ | Increment by one
Main link
Determines if countries are equal, and otherwise calls helper link 5
E? | If both countries equal:
Ɗ | Then, as a monad:
Ḣ | - Head (first country)
,2 | - Pair with 2
K | - Join with spaces
Ç | Else: Call helper link 5
Python 2, 395 332 336 318 313 bytes
def f(c,d):
j,k=[' -'['-'in s]for s in c,d];u=c.split(j);v=d.split(k);n,m=len(u),len(v);D=max(j,k);b=D in c+d
if(n>1)^(m<2):i,j=[choice([i+1for i in range(len(s)-1)if s[i]in['aeiouAEIOU',' -'][b]])for s in c,d];R=c[:i-b]+b*D+d[j:]
else:R=D.join((u[:-1]or u)+v[m>1:])
return[R,c+' 2'][c==d]
from random import*
Try it online!
17 bytes thx to Value Ink; and a hat tip to SztupY for pointing out a bug.
C# (Visual C# Interactive Compiler), 242 bytes
a=>b=>a==b?a+" 2":((d=a.LastIndexOfAny(z=((j=new[]{a,b}.Count(x=>"- ".Any(x.Contains)))>0?"- ":"aeiouAEIOU").ToArray()))<0?a:a.Remove(d+1))+b.Remove(0,j+new Random().Next()>0?(d=b.IndexOfAny(z)-j%2+1)<0?0:d:b.LastIndexOfAny(z));dynamic z,d,j;
Try it online!