Translate English to Corpus

14

1

The Corpus are a fictional faction from the popular video game Warframe who have a somewhat interesting language.

Whilst other factions in the game such as the Grineer have some logic behind their language, the Corpus is simply a lossy substitution of the English language.

All Corpus words are the same as their English counterparts, except with the following alphabetical mappings:

English to Corpus mapping

This causes some problems with pronunciation as:

yes becomes yey
say becomes yay
yay becomes yay
sassy becomes yayyy
case becomes yaye

Here's a text version of the mappings:

a -> a
b -> t
c -> y
d -> p
e -> e
f -> t
g -> j
h -> k
i -> i
j -> t
k -> k
l -> p
m -> s
n -> t
o -> o
p -> k
q -> r
r -> t
s -> y
t -> p
u -> u
v -> t
w -> j
x -> k
y -> y
z -> b

The challenge

Given text using the English alphabet, output its Corpus translation.

For example, the text Hello, World! becomes Keppo, Jotpp! in Corpus

The Rules

  • Input will only consist of ASCII printable characters
  • Input text may contain whitespace and punctuation, these must be preserved
  • Capitalization of letters must be preserved
  • This is so naturally, fewest bytes wins!

The Testcases

Test cases are separated with <===========>, with a blank line between input and expected output

Hello, World!

Keppo, Jotpp!
<===========>
Yes

Yey
<===========>
TestcaSe

PeypyaYe
<===========>
Programming Puzzles and Code Golf

Ktojtassitj Kubbpey atp Yope Jopt
<===========>
This text has a
newline in it

Pkiy pekp kay a
tejpite it ip
<===========>
Corpus language best language

Yotkuy patjuaje teyp patjuaje
<===========>
Strip the flesh! Salt the wounds!

Yptik pke tpeyk! Yapp pke joutpy!
<===========>
"Install Warframe" they said, "It'll be fun" they said

"Itypapp Jatttase" pkey yaip, "Ip'pp te tut" pkey yaip
<===========>
What the **** did you just ****ing say about me, you little *****?
I'll have you know I graduated top of my class in the Navy Seals,
and I've been involved in numerous secret raids on Al-Quaeda,
and I have over 300 confirmed kills.

Jkap pke **** pip you tuyp ****itj yay atoup se, you pipppe *****?
I'pp kate you ktoj I jtapuapep pok ot sy ypayy it pke Taty Yeapy,
atp I'te teet ittoptep it tusetouy yeytep taipy ot Ap-Ruaepa,
atp I kate otet 300 yottitsep kippy.

The Bonus

If you also include an audio recording (or video with audio) of you pronouncing each of the testcase's Corpus translations, you may multiply your bytecount by 1 as a reward.

Skidsdev

Posted 2018-12-20T19:10:55.337

Reputation: 9 656

@Shaggy Sure, shoulda thought of that – Skidsdev – 2018-12-20T19:25:21.807

4@RobertS. it also provides no bonus to your score (x * 1 == x). It's a tongue-in-cheek poke at the unpronouncability of many of the translations – Skidsdev – 2018-12-20T19:38:37.460

1Can output be an array of characters? – ElPedro – 2018-12-20T21:23:15.413

@Skidsdev The "translations" are pronounceable; either as a recorded human voice or programmatically using machine learning and/or text-to-speech technologies. – guest271314 – 2018-12-20T22:19:29.457

@ngn oops my bad, copied from reddit :P – Skidsdev – 2018-12-21T13:44:43.500

I showed this to a friend and now he's translating his texts. It's really hard to translate back because it's lossy (not one-to-one).

Help. – bxk21 – 2018-12-21T21:58:55.167

1And so was born the Finnish language! – sergiol – 2018-12-26T21:43:07.287

Answers

7

Bash + coreutils, 46

tr b-zB-Z ${a=typetjkitkpstokrtyputjkyb}${a^^}

Try it online!

Digital Trauma

Posted 2018-12-20T19:10:55.337

Reputation: 64 644

4

T-SQL, 107 Bytes

SELECT TRANSLATE(v,'bcdfghjlmnpqrstvwxzBCDFGHJLMNPQRSTVWXZ',
                   'typtjktpstkrtyptjkbTYPTJKTPSTKRTYPTJKB')FROM t

Line break and indent are for readability only.

Uses the SQL 2017 function TRANSLATE for character replacement.

Unfortunately had to put (almost) the entire alphabet in there twice to maintain casing. There are probably better ways, maybe something that handles the t's as a group, but this worked for me.

Input is via a pre-existing table t with varchar column v, per our IO rules.

In this case the table must be created using a case-sensitive collation, either by running on a case-sensitive server, or by using the COLLATE keyword (not counted toward character total):

CREATE TABLE t(v varchar(999) COLLATE Latin1_General_CS_AS)

BradC

Posted 2018-12-20T19:10:55.337

Reputation: 6 099

4

05AB1E, 24 bytes

ži.•ÜÁ©;«ìñä°ÔG·ÖYΘ•Du«‡

Explanation:

                       ‡   transliterate
ži                         a-zA-Z with
  .•ÜÁ©;«ìñä°ÔG·ÖYΘ•       atypetjkitkpstokrtyputjkyb
                    Du«    concatenated with itself, uppercased

Try it online!

Okx

Posted 2018-12-20T19:10:55.337

Reputation: 15 025

Minor 24 bytes alternative by transliterating just the consonants.

– Kevin Cruijssen – 2018-12-22T17:29:20.660

4

Charcoal, 42 bytes

≔”$⌊∧T-¶I^F⁷ü@n⁹γ›7η”η⭆θ⎇№β↧ι§⎇№βι↧ηη⌕β↧ιι

Try it online! Link is to verbose version of code. Explanation:

≔                       Assign
 ”$⌊∧T-¶I^F⁷ü@n⁹γ›7η”  Compressed string `ATYPETJKITKPSTOKRTYPUTJKYB` 
                     η  To variable

 θ                      Input string
⭆                       Map over characters and join
  ⎇                     If
    β                   Lowercase alphabet
   №                    Contains
      ι                 Current character
     ↧                  Lowercased
                        (Then)
        ⎇               If
          β             Lowercase alphabet
         №              Contains
           ι            Current character
                        (Then)
             η          Variable
            ↧           Lowercased
                        (Else)
              η         Variable
       §                Indexed by
               ⌕        Index of
                  ι     Current character
                 ↧      Lowercased
                β       In lowercase alphabet
                        (Else)
                   ι    Current character
                        Implicitly print

Neil

Posted 2018-12-20T19:10:55.337

Reputation: 95 035

3

JavaScript (Node.js), 100 bytes

s=>s.replace(/[a-z]/gi,c=>(C='_atypetjkitkpstokrtyputjkyb'[Buffer(c)[0]&31],c>{}?C:C.toUpperCase()))

Try it online!

s =>                                  // s = input string
  s.replace(                          // replace in s ...
    /[a-z]/gi,                        // ... all letters, no matter the case
    c => (                            // for each letter c:
      C =                             //   pick a replacement letter C
        '_atypetjkitkpstokrtyputjkyb' //   from a 1-indexed lookup string
        [Buffer(c)[0] & 31],          //   using the 5 lowest bits of the ASCII code of c
      c > {} ?                        //   if the original letter was in lower case:
        C                             //     use the replacement letter as-is
      :                               //   else:
        C.toUpperCase()               //     convert it to upper case
    )                                 // 
  )                                   // end of replace()

Arnauld

Posted 2018-12-20T19:10:55.337

Reputation: 111 334

3

R, 79 bytes

function(x)chartr("b-zB-Z",paste0(y<-"typetjkitkpstokrtyputjkyb",toupper(y)),x)

Try it online!

Only 3 bytes shorter than literally typing both lower- and uppercase replacement strings together...

R, 79 bytes

function(x,`[`=chartr)"B-Z"[toupper(y),"b-z"[y<-"typetjkitkpstokrtyputjkyb",x]]

Try it online!

Fancier code, same byte count.

Kirill L.

Posted 2018-12-20T19:10:55.337

Reputation: 6 693

2

Perl 5 -p, 54 bytes

eval"y/B-Zb-z/".uc($a=typetjkitkpstokrtyputjkyb)."$a/"

Try it online!

Xcali

Posted 2018-12-20T19:10:55.337

Reputation: 7 671

2

C# (Visual C# Interactive Compiler), 151 83 bytes

n=>n.Select(a=>char.IsLetter(a)?(char)(" ATYPETJKITKPSTOKRTYPUTJKYB"[a%32]|a&32):a)

Try it online!

Saved a whopping 68 bytes thanks to Pietu1998!

Embodiment of Ignorance

Posted 2018-12-20T19:10:55.337

Reputation: 7 014

You can get this down to 83 bytes by removing the range, combining the Selects and using bitwise operators for casing.

– PurkkaKoodari – 2018-12-21T14:01:00.777

Thanks! Nice trick with the bit wise operators! – Embodiment of Ignorance – 2018-12-21T16:23:31.740

2

Ruby, 55 bytes

$_.tr!"b-zB-Z",(x="typetjkitkpstokrtyputjkyb")+x.upcase

Try it online!

Kirill L.

Posted 2018-12-20T19:10:55.337

Reputation: 6 693

2

J, 78 61 bytes

-17 bytes thanks to FrownyFrog!

rplc(u:,98 66+/i.25);"0(,toupper)@'typetjkitkpstokrtyputjkyb'

Try it online!

Galen Ivanov

Posted 2018-12-20T19:10:55.337

Reputation: 13 815

261 – FrownyFrog – 2018-12-21T10:52:41.013

@FrownyFrog Thanks! In my J804 I can't use constants at the right-hand side. I need to upgrade :) My solution is ugly nevertheless.... – Galen Ivanov – 2018-12-21T11:27:02.853

2

K (ngn/k), 87 63 61 60 59 bytes

f:{`c$x-a-@[!128;98+!25;:;0+"typetjkitkpstokrtyputjkyb"]a:_x}

Try it online!

{ } function with argument x

_ to lowercase

a: assign to a

!128 the list 0 1 2 ... 127

@[!128; indices ;:; values ] amend it by replacing the elements at indices with the given values

98+!25 the list 98 99 100 ... 122 which are the ascii codes for "bcd...z"

juxtaposition is indexing, so we use a (implicitly converted to integers) as indices in the amended list

x-a- subtract from a, then subtract form x; this restores upper/lowercase as in the original string

`c$ convert to characters

ngn

Posted 2018-12-20T19:10:55.337

Reputation: 11 449

1

Retina 0.8.2, 59 bytes

[a-z]
 $&
T`l`L
T`L`ATYP\ETJKITKPST\OKRTYPUTJKYB
T`L `l_` .

Try it online! Link includes test cases. Explanation:

[a-z]
 $&

Prefix a non-ASCII character to each letter. (I tried to use a non-breaking space but Firefox might have changed it back to a regular space after copying and pasting.)

T`l`L

Uppercase all of the letters.

T`L`ATYP\ETJKITKPST\OKRTYPUTJKYB

Convert the letters to Corpus.

T`L `l_` .

Lowercase the letters after the non-ASCII character and delete the non-ASCII character.

Naïve solution is 63 bytes:

T`lL`aty\petjkitk\pst\okrty\putjkybATYP\ETJKITKPST\OKRTYPUTJKYB

Try it online! Link includes test cases.

Neil

Posted 2018-12-20T19:10:55.337

Reputation: 95 035

1

Python 2, 115 bytes

lambda i:i.translate(''.join(a))
a=map(chr,range(256))
b='typetjkitkpstokrtyputjkyb'
a[66:91]=b.upper();a[98:123]=b

Try it online!

Adapted from @ElPedro's answer. This generates the replacement for every ascii character in the array a and then uses str.translate.

Can be brought to 113 bytes if returning an array of chars is acceptable:

lambda i:[a[ord(x)]for x in i]
a=map(chr,range(256))
b='typetjkitkpstokrtyputjkyb'
a[66:91]=b.upper();a[98:123]=b

Try it online!

Black Owl Kai

Posted 2018-12-20T19:10:55.337

Reputation: 980

Took some thinking at this time of night to work out how it was doing it. It's been a long day! Nice solution. – ElPedro – 2018-12-20T23:38:32.763

1

Jelly, 29 bytes

“qḍỊYl4ḃ©ƭṄxḳ½Dy’ṃⱮØA,Øa¤⁺żẎy

Try it online!

Erik the Outgolfer

Posted 2018-12-20T19:10:55.337

Reputation: 38 134

Only need to map consonants, so “ØṖ¦Mṗẏʋ@¥;}/’ṃⱮØCŒH¤⁺żẎy saves 4. (Can't get rid of 'y' with ØY since it's on the right of the map)

– Jonathan Allan – 2018-12-21T19:01:28.000

1

Japt, 37 bytes

;®i`…ypetjkŠkp¡okrtyp©jkyb`pu)gCpu bZ

Try it online!

The above link includes most test cases, but I haven't been able to input the second to last one as a string because it contains both single and double quotes. Here is that test case, input as an array of characters instead.

Explanation:

;                                        #Set C to the lowercase alphabet
 ®                                       #For each character Z of the input:
                                   bZ    # Find its index in:
                               C         #  The lowercase alphabet
                                pu       #  Plus the uppercase alphabet
                                         #  (-1 if it is not a letter)
                              g          # And get the character at that index in:
   `…ypetjkŠkp¡okrtyp©jkyb`              #  Get the lowercase Corpus alphabet
                           pu)           #  Plus the uppercase Corpus alphabet
  i                                      #  Add Z at the end (index -1)

Kamil Drakari

Posted 2018-12-20T19:10:55.337

Reputation: 3 461

0

Python 2, 138 132 bytes

def f(i,a='bcdfghjlmnpqrstvwxz',b='typtjktpstkrtyptjkb'):a+=a.upper();b+=b.upper();return''.join((x,b[a.find(x)])[x in a]for x in i)

Try it online!

Actually shorter with a named function than with a lambda!

lambda version, 138 bytes

lambda i,a='bcdfghjlmnpqrstvwxzBCDFGHJLMNPQRSTVWXZ',b='typtjktpstkrtyptjkbTYPTJKTPSTKRTYPTJKB':''.join((x,b[a.find(x)])[x in a]for x in i)

Try it online!

131 125 if we are allowed to return an array of characters and have the join outside the function.

def f(i,a='bcdfghjlmnpqrstvwxz',b='typtjktpstkrtyptjkb'):a+=a.upper();b+=b.upper();return[(x,b[a.find(x)])[x in a]for x in i]

Try it online!

ElPedro

Posted 2018-12-20T19:10:55.337

Reputation: 5 301

1You can still use a lambda if you make a and b global variables – Black Owl Kai – 2018-12-20T22:58:18.067

@BlackOwlKai - Thanks. Have been playing with that idea but it's getting late. Maybe tomorrow :) – ElPedro – 2018-12-20T22:59:48.773

Got it down to 120/113 characters (TIO without the testcases, else the link would be too long for a comment)

– Black Owl Kai – 2018-12-20T23:08:22.097

Beats mine and different enough for you to post as your own answer. I'll upvote :) – ElPedro – 2018-12-20T23:09:52.067

Feel free to steal my test cases as well. They took longer to type in than the code... – ElPedro – 2018-12-20T23:12:13.667

0

PHP, 100 bytes

Code

<?=strtr($argv[0],($u=bcdfghjklmnpqrstvwxyz).($f=strtoupper)($u),($v=typtjktkpstkrtyptjkyb).$f($v));

Try it online!

Explanation

# using the provided character mapping given on the question, as an array
strtr($argv[0],                                  # strtr for the string replacement
($u=bcdfghjklmnpqrstvwxyz).($f=strtoupper)($u),  # Taking onthe the keys for the first string
($v=typtjktkpstkrtyptjkyb).$f($v));              # Using the values for second string
 # In both Strings appending the upper version of each string.

Francisco Hahn

Posted 2018-12-20T19:10:55.337

Reputation: 591

0

Pyth, 35 Bytes

XQ.*m+r1dd[tG."byàHuH¯¹e?rJyfh

Try it!

Could probably use Left map or something to get rid of the two d's, but I couldn't figure out how.

KarlKastor

Posted 2018-12-20T19:10:55.337

Reputation: 2 352

0

Java, 211 Bytes

a->{String b="BCDFGHJLMNPQRSTVWXZbcdfghjlmnpqrstvwxz",c="TYPTJKTPSTKRTYPTJKBtyptjktpstkrtyptjkb";a.chars().map(x->{int z;return(z=b.indexOf(x))>-1?c.toCharArray()[z]:x;}).forEach(x->System.out.print((char)x));};

Try it online!

Hypino

Posted 2018-12-20T19:10:55.337

Reputation: 221

191 bytes – ceilingcat – 2018-12-27T22:21:20.410

0

Pyth, 34 chars

J."byàHuH¯¹e?rJyfh"XXztGJrtG1rJ1

Try it online!

The string is a compressed version of "typetjkitkpstokrtyputjkyb". For some reason I cannot get Pyth to compress "atypetjkitkpstokrtyputjkyb" with the function

+++\.N++hSzeSzCi-RChSzCMz-hCeSzChSzN
even though it would probably save a byte or two as the two t's could be eliminated.

Lucas Bertocchini

Posted 2018-12-20T19:10:55.337

Reputation: 1

0

Tcl, 114 bytes

proc C s {string map [split {btcydpftgjhkjtlpmsntpkqrrtsytpvtwjxkzbBTCYDPFTGJHKJTLPMSNTPKQRRTSYTPVTWJXKZB} ""] $s}

Try it online!

sergiol

Posted 2018-12-20T19:10:55.337

Reputation: 3 055

0

Lua, 153 bytes

t="atypetjkitkpstokrtyputjkyb"for c in(...):gmatch"."do i=c:lower():byte()-96n=t:sub(i,i)io.write((i<0or i>26)and c or(c==c:upper()and n:upper()or n))end

Try it online!

Visckmart

Posted 2018-12-20T19:10:55.337

Reputation: 151