Created
March 7, 2019 06:53
-
-
Save ishideo/ea0fccec887eb92978e2ec4918bb6a92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * This file was generated by the Gradle 'init' task. | |
| * | |
| * This generated file contains a sample Scala library project to get you started. | |
| * For more details take a look at the Scala plugin chapter in the Gradle | |
| * user guide available at https://docs.gradle.org/5.0/userguide/scala_plugin.html | |
| */ | |
| import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | |
| plugins { | |
| // Apply the scala plugin to add support for Scala | |
| id("scala") | |
| id("application") | |
| id("com.github.johnrengelman.shadow") version "5.0.0" | |
| } | |
| repositories { | |
| // Use jcenter for resolving your dependencies. | |
| // You can declare any Maven/Ivy/file repository here. | |
| jcenter() | |
| } | |
| dependencies { | |
| // Use Scala 2.12 in our library project | |
| implementation("org.scala-lang:scala-library:2.12.7") | |
| implementation("com.ibm.icu:icu4j:63.1") | |
| // Use Scalatest for testing our library | |
| testImplementation("junit:junit:4.12") | |
| testImplementation("org.scalatest:scalatest_2.12:3.0.5") | |
| // Need scala-xml at test runtime | |
| testRuntimeOnly("org.scala-lang.modules:scala-xml_2.12:1.1.1") | |
| } | |
| application { | |
| // Define the main class for the application | |
| mainClassName = "KatakanaRomajiConvert.Main" | |
| } | |
| tasks.withType<Jar> { | |
| manifest { | |
| attributes(mapOf( | |
| "Main-Class" to "KatakanaRomajiConvert.Main" | |
| )) | |
| } | |
| } | |
| tasks.withType<ShadowJar> { | |
| baseName = "kana2romaji" | |
| classifier = "" | |
| version = "" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| org.gradle.jvmargs='-Dfile.encoding=UTF-8' | |
| org.gradle.daemon=true | |
| // org.gradle.java.home=C:\\JDKPortable | |
| // systemProp.http.proxyHost= | |
| // systemProp.http.proxyPort= | |
| // systemProp.https.proxyHost= | |
| // systemProp.https.proxyPort= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package KatakanaRomajiConvert | |
| import com.ibm.icu.text.Transliterator | |
| class KatakanaRomajiConvert(val word: String = "") { | |
| private val transliterator = Transliterator.getInstance("Katakana-Latin") | |
| def toRomaji: String = { | |
| val kana: Option[String] = Some(word) | |
| transliterator.transliterate(kana.getOrElse("")) | |
| } | |
| } | |
| object Main extends App { | |
| if (args.length != 0) { | |
| val katakana: String = args(0) | |
| val katakanaObj = new KatakanaRomajiConvert(katakana) | |
| println(katakanaObj.toRomaji) | |
| } else { | |
| println("") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package KatakanaRomajiConvert | |
| import org.scalatest._ | |
| class KatakanaRomajiConvertSpec extends FlatSpec with Matchers { | |
| "Input strings \"トウキョウ\"" should "output strings toukyou" in { | |
| new KatakanaRomajiConvert("トウキョウ").toRomaji shouldEqual "toukyou" | |
| } | |
| "Input no string" should "" in { | |
| new KatakanaRomajiConvert("").toRomaji shouldEqual "" | |
| } | |
| "Argument is null" should "" in { | |
| new KatakanaRomajiConvert(null).toRomaji shouldEqual "" | |
| } | |
| "No argument" should "" in { | |
| new KatakanaRomajiConvert().toRomaji shouldEqual "" | |
| } | |
| "Input strings \"あいうアイウabcABC\"" should "" in { | |
| new KatakanaRomajiConvert("あいうアイウabcABC").toRomaji shouldEqual "あいうaiuabcABC" | |
| } | |
| "Input strings \"あいう アイウ abc ABC\"" should "" in { | |
| new KatakanaRomajiConvert("あいう アイウ abc ABC").toRomaji shouldEqual "あいう aiu abc ABC" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment