Translate a simple sentence from Toki Pona

12

1

Toki Pona is a linguist's code golf: A minimalist language with a vocabulary of around 120 words. Because of this, it has very few grammatical irregularities found in other languages, making it ideal for a code golf challenge.

Your task is to take the most simple form of a Toki Pona sentence and translate it into English, using the (even more) limited dictionary provided in this question.

The dictionary

While 120 words isn't a lot for a language, it's a lot of bytes. So, for that reason, I'm limiting the input to only contain these 20 words (English translation in brackets, Toki Pona in bold):

  • Pronouns: mi (I/me), sina (you) and ona (he/she/it/him/her)
  • Grammatical constructs: li and e
  • Verbs: jo (to have), moku (to eat), pona (to fix), oko (to see) and wile (to want)
  • Adjectives: pona (good/simple), ike (bad), wan (one/unique) and mute (many)
  • Nouns: kili (fruit), oko (eye), jan (person/man/woman), moku (food), ilo (tool) and ijo (thing)

In addition, sentences involving the verb to be are included (expanded on later).

As you can see, simple sentences such as I want food can be made from this list: mi wile e moku. We'll address the exact grammatical construction in the next section. However, note that a single word may be used for multiple different English words (e.g. moku), which is how such a limited vocabulary is possible.

Grammar

All of the sentences you'll be required to handle will have one of the following forms:

  • pronoun/noun "li" verb
    • e.g. ona li oko (he sees)
  • pronoun/noun "li" pronoun/noun
    • e.g. ona li jan (she is a person)
  • pronoun/noun "li" noun adjective
    • e.g. ona li ijo ike (it is a bad thing)
  • pronoun/noun "li" verb "e" pronoun/noun
    • e.g. jan li jo e kili (the person has fruit)
  • pronoun/noun "li" verb "e" noun adjective
    • e.g. jan li jo e kili pona (the person has good fruit)

We'll call the first pronoun/noun the subject of the sentence and the second the object. Notice that the adjective comes after the noun, not before, and that pronouns cannot be paired with adjectives.

For example, ona li moku e moku (He eats food) is of the fourth form. However, the one exception is that if the subject is mi (I/me) or sina (you), then li is omitted. So mi moku e moku would translate as I eat food.

You'll notice that forms 2 and 3 don't have a verb, but our translated examples do. This is because Toki Pona has no word for to be. While we would say "I am good", Toki Pona speakers would say mi pona instead (omitting the verb). If the subject is not mi or sina, then li is used as it would be usually: kili li moku.

The two constructs li and e are used in the following ways:

  • If the pronoun preceding is not mi or sina, the verb in the sentence is preceded by li. For example, moku li moku or ona li oko
  • The object in the sentence is always preceded by e. For example, moku li moku e moku or mi pona e ilo mute.

Notice that Toki Pona doesn't conjugate verbs, nor does it change the word when plural. Due to this, you should assume that all input is in the singular (ijo is translated as thing, not things)

English translation

In comparison, all outputted sentences should be in the forms

  • pronoun/noun verb
  • pronoun/noun verb pronoun/noun
  • pronoun/noun verb adjective pronoun/noun

As each word has multiple translations (ona is he, she or it), we'll use these translations:

mi   (subject)   -> I
mi   (object)    -> me
sina             -> you
ona  (subject)   -> he
ona  (object)    -> him
jo               -> to have
moku (verb)      -> to eat
moku (noun)      -> food
pona (verb)      -> to fix
pona (adjective) -> good
oko  (verb)      -> to see
oko  (noun)      -> eye
wile             -> to want
ike              -> bad
wan              -> one
mute             -> many
kili             -> fruit
jan              -> person
ilo              -> tool
ijo              -> thing

However, because English has plenty of grammatical irregularities, and we have such a small vocabulary list, the English output should be as accurate as possible. Therefore:

  • Verbs in English are to be conjugated. This means that for all verbs except to be:
    • The I and you forms are the same as the infinitive (to fix -> I fix, you fix etc.)
    • The he form (which includes nouns) modifies the infinitive to end with an s. Specfically, the 5 verbs become has, eats, fixes, sees and wants respectively.
  • For to be, I becomes am, you becomes are and he (including nouns) become is
  • Nouns are prefixed with a the (notice the space), unless the adjective after it is wan (one) or mute (many).
  • Nouns before mute (many) should have a trailing s (yes even fruit and food). So ilo mute becomes many tools

Your task

You are to take in a single sentence of Toki Pona consisting of only words from those 20, and always in one of the forms listed above (including the to be exceptions), and output the English translation. As is standard in Toki Pona, input will always be lowercase.

You may take input where the separator is any consistent non-alphabetic character or sequence of characters, including spaces (i.e. mi@@@e@@@jan is perfectly acceptable), or you may take input as a list of words, if you wish. The input does not have to make sense (e.g. ijo li jo e jan mute), but will always follow the grammatical rules.

Output rules are equally lax - you may output as a list of words, or as a single string with any consistent, non-alphabetical separator. Case is irrelevant.

This is so the shortest code in bytes wins!

Test cases

mi wile e moku - I want the food
mi moku e moku - I eat the food
mi pona - I fix+
mi jan - I am the person
ona li oko - He sees/He is the eye*
ona li jan - He is the person
ona li ijo ike - He is the bad thing
jan li jo e kili - The person has the fruit
jan li oko e kili pona - The person sees the good fruit
kili li moku - The fruit is the food/The fruit eats*
moku li moku - The food is the food/The food eats*
moku li moku e moku - The food eats the food
ijo li jo e jan mute - The thing has many persons
ilo li pona e ijo - The tool fixes the thing
sina moku e kili mute - You eat many fruits
sina moku e kili ike - You eat the bad fruit
oko li oko e mi - The eye sees me
mi wile e sina - I want you
jan li moku e ona - The person eats him
mi jo e ijo wan - I have one thing
mi jo e ijo mute - I have many things
sina kili - you are the fruit

*: Either translation is acceptable for output, as both are valid translations
+: I am good would be the natural translation, but using pona as an adjective doesn't fix as one of our five forms, so is not a valid translation in this case

caird coinheringaahing

Posted 2019-11-01T02:33:41.257

Reputation: 13 702

1Sandbox. I have aimed to be as comprehensive as possible with the test cases, but please comment if you would like any more/a specific test case – caird coinheringaahing – 2019-11-01T02:34:17.243

3"Pronouns: mi (I/me), sina (you) and ona (he/she/it/him/her)" Just hope that this question doesn't fall afoul of the Code of Conduct and get us all suspended. – ouflak – 2019-11-01T07:36:08.193

'I am good' shouldn't be included, because it's a noun/pronoun "li" adjective, the schema is not listed above – Alexey Burdin – 2019-11-01T14:20:06.917

@AlexeyBurdin It is, but in this case the li is omitted, as the pronoun is mi. I thought it would be better to have an single exception to the rule, rather than list an additional 5 rules just to cover mi/sina. – caird coinheringaahing – 2019-11-01T15:26:49.593

I see, I mean other thing: only noun, verb, pronoun is allowed after "li" even if "li" is omitted, but here is adjective after "li" in 'I am good'. – Alexey Burdin – 2019-11-01T15:36:02.463

Also why isn't 'you' capitalized in the beginning of a sentence? – Alexey Burdin – 2019-11-01T15:45:50.963

1@AlexeyBurdin I understand now, yes you are correct, mi pona doesn't fit any form when pona is used as an adjective. I've fixed the test case, and added a note about that specific case. The you wasn't capitalised due to a typo - it has now been fixed. – caird coinheringaahing – 2019-11-01T15:49:19.157

The list of test cases translated into English read like the lyrics of some '70s Talking Heads song. Same as it ever was! – Chas Brown – 2019-11-02T02:22:42.170

1@Arnauld Added, thanks! – caird coinheringaahing – 2019-11-03T00:03:40.003

@Arnauld Ah yes, my bad – caird coinheringaahing – 2019-11-03T00:21:13.857

Answers

7

JavaScript (ES6),  498 ... 447  445 bytes

Outputs in lowercase, except for 'I'.

s=>(s.replace(/\w+/g,w=>(x='2want||2eat/5food||5you|2see/5eye|5thing|1I/4me|5person|8many|8bad|5fruit|1he/4him|5tool||2fix/8good||2have||8one'.split`|`[n=parseInt(w,35)%781%21])&&(x=(g=_=>x.split`/`.find(x=>x[0]>>t&1,t++)||g())(),o[t]=x.slice(1),O[t]=n),o=[t=-1],O=[]))&&([s,v,o,a]=o,[S,V,O,A]=O,g=n=>4241>>n&1?'':'the ')(S)+s+` ${y=144>>S&1,1/V?V^17|y?v:'ha':S^4?S^7?'i':'am':'are'}${y?'':V^15?'s':'es'} `+g(A%10^9&&O)+[a&&a+' ']+[o]+['s'[A^9]]

Try it online!

How?

We first split the input string \$s\$ into words and interpret each of them as an integer in base \$35\$, modulo \$781\$ and modulo \$21\$, which gives a unique ID \$n\$ in \$[0..19]\$. We associate a data string to each ID as follows:

 word   | base 35 to decimal | mod 781 | mod 21 | data
--------+--------------------+---------+--------+--------------
 'mi'   |                788 |       7 |      7 | '1I/4me'
 'sina' |            1223365 |     319 |      4 | '5you'
 'ona'  |              30215 |     537 |     12 | '1he/4him'
 'jo'   |                689 |     689 |     17 | '2have'
 'moku' |             973380 |     254 |      2 | '2eat/5food'
 'pona' |            1102090 |      99 |     15 | '2fix/8good'
 'oko'  |              30124 |     446 |      5 | '2see/5eye'
 'wile' |            1394799 |     714 |      0 | '2want'
 'ike'  |              22764 |     115 |     10 | '8bad'
 'wan'  |              39573 |     523 |     19 | '8one'
 'mute' |             981029 |      93 |      9 | '8many'
 'kili' |             880303 |     116 |     11 | '5fruit'
 'jan'  |              23648 |     218 |      8 | '5person'
 'ilo'  |              22809 |     160 |     13 | '5tool'
 'ijo'  |              22739 |      90 |      6 | '5thing'
 'li'   |                753 |     753 |     18 | ''
 'e'    |                 14 |      14 |     14 | ''

We keep track of the expected type of the next word in the variable \$t\$:

  • \$t=0\$: subject
  • \$t=1\$: verb
  • \$t=2\$: object
  • \$t=3\$: adjective

The leading digit in front of each translated word is a bitmask describing the types that the word can be associated with. For instance, "5fruit" means that "fruit" may be either the subject (\$2^0=1\$) or the object (\$2^2=4\$) of the sentence.

We use this information to assign the relevant type to each input word. At the end of this process, the array [s,v,o,a] holds the categorized words (subject, verb, object and adjective, respectively) while the array [S,V,O,A] holds the corresponding indices, as described in the penultimate column of the above table.

Using these variables, we can finally apply English rules to translate the sentence.

Arnauld

Posted 2019-11-01T02:33:41.257

Reputation: 111 334

2

Python 3, 1902 bytes


import re
p='mi|sina|ona'
v='jo|moku|pona|oko|wile'
a='pona|ike|wan|mute'
n='kili|oko|jan|moku|ilo|ijo'
pn=p+'|'+n
d={'p':p,'v':v,'a':a,'n':n,'pn':pn,'li':'li','e':'e',
   'f':'(?:(?:'+pn+') li|(?:mi|sina))'}
g=['f '+i for i in 'v,pn,n a,v e pn,v e n a'.split(',')]
ma=[re.compile('^%s$'%re.subn(r'\w+',lambda m:'({%s})'%m.group(0),i)[0].format(**d))
    for i in g]
tr0=lambda ph:[m.match(ph) and m.match(ph).groups() for m in ma]
d_={'s':{'mi':'I','sina':'you','ona':'he'},'o':{'mi':'me','sina':'you','ona':'him'},'v':{'jo':'have','moku':'eat','pona':'fix','oko':'see','wile':'want'},'n':{'moku':'food','oko':'eye','kili':'fruit','jan':'person','ilo':'tool','ijo':'thing'},'a':{'pona':'good','ike':'bad','wan':'one','mute':'many'}}
md=lambda x:dict((k,v) for i in x for k,v in d_[i].items())
d_['pn']=md('on')
d_['f']=md('sn')
d_['e']={'e':'_'}
mc=lambda x:lambda t:(lambda d:d[t] if t in d else d['_'])(x)
be=mc({'I':'am','you':'are','_':'is'})
vs=lambda p:list(d_[p].values())
os=vs('o')+vs('s')
tr=lambda x:[(n_,[d_[p][w if n else w.split(' ')[0]] \
              for n,(w,p) in enumerate(zip(i,pt.split(' ')))]) \
             for n_,(i,pt) in enumerate(zip(x,g)) if i]
noun=lambda t:lambda n:n if n in os else t+n
the=noun('the ')
the2=lambda n:'' if n in os else 'the '
v_=mc({'I':'','you':'','_':'s'})
m_=lambda o,a:('s' if (a == 'many') and (o not in os) else '')
tr_={0:lambda n,v:[the(n),
                   v+v_(n)],
     3:lambda s,v,e,o:[the(s),v+v_(s),the(o)],
     1:lambda s,o:[the(s),be(s),the(o)],
     2:lambda s,o,a:[the(s),be(s),the2(o)+a,o+m_(o,a)],
     4:lambda s,v,e,o,a:[the(s),v+v_(s),the2(o)+a,o+m_(o,a)],
     }
from functools import reduce
f_={'haves':'has','fixs':'fixes','the one':'one','the many':'many'}
fx=lambda s:reduce(lambda x,y:x.replace(y[0],y[1]),f_.items(),s)
c=lambda s:s[0].upper()+s[1:]
r=lambda s:[(n,c(fx(' '.join(tr_[n](*a))))) for n,a in tr(tr0(s))]

Try it online!

The function r does the thing.
The testing:


s=r'''mi wile e moku - I want the food
mi moku e moku - I eat the food
mi pona - I am good/I fix*
mi jan - I am the person
ona li oko - He sees/He is the eye*
ona li jan - He is the person
ona li ijo ike - He is the bad thing
jan li jo e kili - The person has the fruit
jan li oko e kili pona - The person sees the good fruit
kili li moku - The fruit is the food/The fruit eats*
moku li moku - The food is the food/The food eats*
moku li moku e moku - The food eats the food
ijo li jo e jan mute - The thing has many persons
ilo li pona e ijo - The tool fixes the thing
sina moku e kili mute - you eat many fruits
sina moku e kili ike - you eat the bad fruit
oko li oko e mi - The eye sees me
mi wile e sina - I want you
jan li moku e ona - The person eats him
mi jo e ijo wan - I have one thing
mi jo e ijo mute - I have many things'''.split('\n')
print('\n'.join(str((r(j.split(' - ')[0]),
                     j.split(' - ')[1].rstrip('*').split('/'))) \
                for j in s))

The test output:


([(3, 'I want the food')], ['I want the food'])
([(3, 'I eat the food')], ['I eat the food'])
([(0, 'I fix')], ['I am good', 'I fix'])
([(1, 'I am the person')], ['I am the person'])
([(0, 'He sees'), (1, 'He is the eye')], ['He sees', 'He is the eye'])
([(1, 'He is the person')], ['He is the person'])
([(2, 'He is the bad thing')], ['He is the bad thing'])
([(3, 'The person has the fruit')], ['The person has the fruit'])
([(4, 'The person sees the good fruit')], ['The person sees the good fruit'])
([(0, 'The fruit eats'), (1, 'The fruit is the food')], ['The fruit is the food', 'The fruit eats'])
([(0, 'The food eats'), (1, 'The food is the food')], ['The food is the food', 'The food eats'])
([(3, 'The food eats the food')], ['The food eats the food'])
([(4, 'The thing has many persons')], ['The thing has many persons'])
([(3, 'The tool fixes the thing')], ['The tool fixes the thing'])
([(4, 'You eat many fruits')], ['you eat many fruits'])
([(4, 'You eat the bad fruit')], ['you eat the bad fruit'])
([(3, 'The eye sees me')], ['The eye sees me'])
([(3, 'I want you')], ['I want you'])
([(3, 'The person eats him')], ['The person eats him'])
([(4, 'I have one thing')], ['I have one thing'])
([(4, 'I have many things')], ['I have many things'])

The raw thing:


import re
p='mi|sina|ona'
v='jo|moku|pona|oko|wile'
a='pona|ike|wan|mute'
n='kili|oko|jan|moku|ilo|ijo'
pn=p+'|'+n
d={'p':p,'v':v,'a':a,'n':n,'pn':pn,'li':'li','e':'e',
   'f':'(?:(?:'+pn+') li|(?:mi|sina))'}
g=['f '+i for i in 'v,pn,n a,v e pn,v e n a'.split(',')]
ma=[re.compile('^%s$'%re.subn(r'\w+',lambda m:'({%s})'%m.group(0),i)[0].format(**d))
    for i in g]
s=r'''mi wile e moku - I want the food
mi moku e moku - I eat the food
mi pona - I am good/I fix*
mi jan - I am the person
ona li oko - He sees/He is the eye*
ona li jan - He is the person
ona li ijo ike - He is the bad thing
jan li jo e kili - The person has the fruit
jan li oko e kili pona - The person sees the good fruit
kili li moku - The fruit is the food/The fruit eats*
moku li moku - The food is the food/The food eats*
moku li moku e moku - The food eats the food
ijo li jo e jan mute - The thing has many persons
ilo li pona e ijo - The tool fixes the thing
sina moku e kili mute - you eat many fruits
sina moku e kili ike - you eat the bad fruit
oko li oko e mi - The eye sees me
mi wile e sina - I want you
jan li moku e ona - The person eats him
mi jo e ijo wan - I have one thing
mi jo e ijo mute - I have many things'''.split('\n')
x=[(lambda ph:[m.match(ph) and m.match(ph).groups() for m in ma])\
   (i.split(' - ')[0]) for i in s]
y=r'''mi   (subject)   -> I
mi   (object)    -> me
sina (subject)            -> you
sina (object)            -> you
ona  (subject)   -> he
ona  (object)    -> him
jo   (verb)            -> to have
moku (verb)      -> to eat
moku (noun)      -> food
pona (verb)      -> to fix
pona (adjective) -> good
oko  (verb)      -> to see
oko  (noun)      -> eye
wile (verb)            -> to want
ike  (adjective)            -> bad
wan  (adjective)            -> one
mute (adjective)            -> many
kili (noun)            -> fruit
jan  (noun)            -> person
ilo  (noun)            -> tool
ijo  (noun)            -> thing'''
from collections import defaultdict
d_=defaultdict(dict)
for w,p,t in re.findall(r'(\w+)\s*\((\w+)\)\s*\-\>\s*(?:to )?(\w+)',y):
    d_[p[0]][w]=t
md=lambda x:dict((k,v) for i in x for k,v in d_[i].items())
d_['pn']=md('on')
d_['f']=md('sn')
d_['e']={'e':'_'}
#print(d_)
mc=lambda x:lambda t:(lambda d:d[t] if t in d else d['_'])(x)
be=mc({'I':'am','you':'are','_':'is'})
hv=mc({'I':'have','you':'have','_':'has'})
vs=lambda p:list(d_[p].values())
tr=lambda x:[(n_,[d_[p][w if n else w.split(' ')[0]] \
              for n,(w,p) in enumerate(zip(i,pt.split(' ')))]) \
             for n_,(i,pt) in enumerate(zip(x,g)) if i]
#print('\n'.join(str((tr(i),j.split(' - ')[1].rstrip('*').split('/'))) \
#                for i,j in zip(x,s)))
noun=lambda t:lambda n:n if n in vs('o')+vs('s') else t+n
the=noun('the ')
the2=lambda n:'' if n in vs('o')+vs('s') else 'the '
v_=mc({'I':'','you':'','_':'s'})
a_=lambda s:('the ' if s not in vs('p') else '')
m_=lambda o,a:('s' if (a == 'many') and (o not in vs('o')+vs('s')) else '')
tr_={0:lambda n,v:[the(n),
                   v+v_(n)],
     3:lambda s,v,e,o:[the(s),v+v_(s),the(o)],
     1:lambda s,o:[the(s),be(s),the(o)],
     2:lambda s,o,a:[the(s),be(s),the2(o)+a,o+m_(o,a)],
     4:lambda s,v,e,o,a:[the(s),v+v_(s),the2(o)+a,o+m_(o,a)],
     }
from functools import reduce
f_={'haves':'has','fixs':'fixes','the one':'one','the many':'many'}
fx=lambda s:reduce(lambda x,y:x.replace(y[0],y[1]),f_.items(),s)
c=lambda s:s[0].upper()+s[1:]
print('\n'.join(str(([(n,c(fx(' '.join(tr_[n](*a))))) for n,a in tr(i)],
                     j.split(' - ')[1].rstrip('*').split('/'))) \
                for i,j in zip(x,s)))
#print('\n'.join(map(str,x)))

You can run it to see it passes all the cases)

Alexey Burdin

Posted 2019-11-01T02:33:41.257

Reputation: 844

I see I can squeeze out 50-100 bytes but it doesn't matter much for 1.9k ) – Alexey Burdin – 2019-11-01T17:08:42.353

This is very impressive! However, why is the output for jan li oko e kili pona [(4, 'The person sees the good fruit')]? What's with the additional wrapping/array/number? – caird coinheringaahing – 2019-11-01T17:27:29.117

1

I've edited your answer slightly to include a link to a testing site. In addition, I've managed to golf -450 bytes with some very weird tricks, including fixing the output format

– caird coinheringaahing – 2019-11-01T19:18:21.647

Awesome. I thought of ~300 bytes including a if b else c to [a,c][b] and optimizing functions. Very impressive. – Alexey Burdin – 2019-11-02T00:53:06.703

1

Jelly, 257 249 bytes

OP€%59µ“:¤¥“ ı“¦1"ø“/“2¿“#“,3‘œiⱮ¹Ƈ’S,@ɗ>5Ḣ$¡"J1,3yƊ$ḢW;1,6y$1¦€ƲḢ,2,3;Ʋ2,1œị=3Ʋ¡+2¦=2Ḣ$¡€58,3iⱮ×7ḢƲḣ;Ṛḣ¥ɗL=4Ɗ¡2+2¦e€3,4Ḣ$¡€1,3¦7œị“¢ṇḃ#ṅ³©½øỴ£⁺Ṭḥ*4=LƤ`:[?SœGʠṂ4£¤ɦ5Ẉḃ⁵ƓOqȤ2MœṁṾġqÐU¤¶ṀẆ¶`ƝUḋ#ḳ#Ạ4Ẏ[`-ckṫ©4%ṙẎọkɲẠ¶{t}6ọ6Ṇ»ỴḲ€“the ”;Ɱ;@Ɗ€3,4¦¤K;11e”sxƲ

Try it online!

A monadic link taking a list of words and returning a string. I’m sure this can be better golfed, but I was just pleased to have something that worked despite the various complexities of the English language!

Explanation

Stage 1

Convert to initial pairs of integers

Note the first of each pair is initially 1 for pronouns, 2 for verbs, 3 for nouns, 4 for adjectives, 5 for quantifiers, 6 for verb/adjective and 7 for verb/noun

O                   | Convert to Unicode codepoints
 P€                 | Product of each word
   %59              | Mod 59
      µ             | Start a new monadic chain
       “:...3‘œiⱮ   | Multidimensional index of this in [[58, 3, 4], [32, 25], [5, 49, 34, 29], 47, [50, 11], 35, [44, 51]]
                 ¹Ƈ | Filter ones that weren’t found (li and e)

Stage 2

Determine meaning for words with two possible meanings; works because nouns can only appear in positions 1 and 3, verbs only in position 2 and adjectives in position 4

                 $ | Following as a monad:
          "     Ɗ  | - Map a link using the following as a monad as the right argument zipped with each element of the input to stage 2 as the left
           J       |   - Index along list
            1,3y   |   - Substitute 1s for 3s (words in the first position 
        $¡         | - If:
     >5            |   - Greater than 5
       Ḣ           |   - Head (i.e. if first number is >5)
                   | - Then:
’                  |   - Increment both items in the pair by 1
 S                 |   - Sum
  ,@               |   - Pair the right argument with this

Stage 3

Change pronouns appearing after position 1 to have 6 as their first integer (so that object versions can be used)

            Ʋ | Following as a monad:
Ḣ             | - Head
 W            | - Wrap in a list
  ;           | - Concatenate to:
   1,6y$1¦€   |   - The other list members at input to stage 3, with 1 replaced by 6

Stage 4

Insert ‘to be’ if there is no verb

              Ɗ¡ | If:
       2,1œị     | - the word type of the second word
            =3   | - is equal to 3 (noun)
      Ʋ          | Then following as a monad:
Ḣ                | - Head
 ,2,3            | - Pair with [2,3] (verb to be)
     ;           | - Concatenate to rest of list

Stage 5

If first word is ‘I’ or ‘you’, add 7 or 14 respectively to the verb number

      $¡€           | For each word, if:
   =2               | - Equals 2
     Ḣ              | - Head (i.e. if word is a noun)
+2¦               Ʋ | Add to the second item (word number) the following as a monad:
         58,3iⱮ     | - Index of mod 59 words (from stage 1) within 58 (I), 3 (you)
               ×7   | - Multiply by 7
                 Ḣ  | - Head (i.e. 7 if first word is ‘I’ and 14 if first word is ‘you’.

Stage 6

Swap noun and adjective or quantifier around if present

         Ɗ¡  | If (as a monad):
      L      | - Length
       =4    | - Equals 4
     ɗ     2 | Then (as a dyad), using 2 as the right argument:
ḣ            | - First 2 words
 ;  ¥        | - Concatenated to following as a dyad:
  Ṛ          |   - Reverse
   ḣ         |   - First two words (i.e. last 2 words in reverse order)

Stage 7

Use version of nouns and adjectives with preceding ‘the’ if they appear in the third or first position

           €1,3¦  | For each of first and third words
         $¡       | - If (as a monad):
   e€3,4          |   - Is one of 3 or 4
        Ḣ         |   - Head (i.e. if word type is noun or adjective)
                  | - Then:
+2¦             7 |   - Add 7 to the second item (i.e. word number)

Stage 8

Index into word list

œị                          ¤ | Multidimensional index into following as a nilad
  “¢...Ṇ»                     | - “I you he/wants has is  fixes eats sees want have am  fix eat see want have are  fix eat see/fruit person tool thing  food eye/good bad/one many/me you him” where / indicates newline
         Ỵ                    | - Split at newlines
          Ḳ€                  | - Split each at spaces
                      Ɗ€3,4¦  | - For each of the third and fourth lists of words, do the following as a monad:
            “the ”;Ɱ          |   - Concatenate “the “ to each
                    ;@        |   - Concatenate to end of list

Stage 9

Add “s” to end if many is used

K         | Join with spaces
 ;      Ʋ | Concatenate to the following as a monad (applied to the mod 59 words from stage 1)
  11e     | - Contains 11 (many)
     ”sx  | - that many “s”

Nick Kennedy

Posted 2019-11-01T02:33:41.257

Reputation: 11 829