File tree Expand file tree Collapse file tree 7 files changed +30
-18
lines changed
src/main/kotlin/com/github/azurapi/azurapikotlin Expand file tree Collapse file tree 7 files changed +30
-18
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## 3.1.3 (2020-18-02)
4
+
5
+ ### Bug fixes
6
+
7
+ - Fix case sensitive option in ` getShipById `
8
+
3
9
## 3.1.2 (2020-01-26)
4
10
5
11
### Bug fixes
@@ -70,4 +76,4 @@ Pre release
70
76
71
77
- ** getShipByName** : returns the closest ship which name matches the requested name
72
78
- ** getShipById** : returns ship with the given ID
73
- - ** getAllShips** : returns a list of all available ships in database
79
+ - ** getAllShips** : returns a list of all available ships in database
Original file line number Diff line number Diff line change @@ -4,13 +4,13 @@ val spekVersion = "2.0.9"
4
4
5
5
plugins {
6
6
java
7
- ` maven- publish`
7
+ maven
8
8
kotlin(" jvm" ) version " 1.3.61"
9
9
id(" org.jmailen.kotlinter" ) version " 2.3.0"
10
10
}
11
11
12
12
group = " com.github.AzurApi"
13
- version = " 2.0.1 "
13
+ version = " 3.1.3 "
14
14
15
15
java {
16
16
sourceCompatibility = JavaVersion .VERSION_1_8
Original file line number Diff line number Diff line change 1
1
distributionBase =GRADLE_USER_HOME
2
2
distributionPath =wrapper/dists
3
- distributionUrl =https\://services.gradle.org/distributions/gradle-6.1.1 -bin.zip
3
+ distributionUrl =https\://services.gradle.org/distributions/gradle-6.2 -bin.zip
4
4
zipStoreBase =GRADLE_USER_HOME
5
5
zipStorePath =wrapper/dists
Original file line number Diff line number Diff line change @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
29
29
set APP_BASE_NAME = %~n0
30
30
set APP_HOME = %DIRNAME%
31
31
32
+ @ rem Resolve any "." and ".." in APP_HOME to make it shorter.
33
+ for %%i in (" %APP_HOME% " ) do set APP_HOME = %%~fi
34
+
32
35
@ rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33
36
set DEFAULT_JVM_OPTS = " -Xmx64m" " -Xms64m"
34
37
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ import com.github.azurapi.azurapikotlin.internal.exceptions.DatabaseException
8
8
import com.github.azurapi.azurapikotlin.internal.exceptions.ShipNotFoundException
9
9
import com.github.azurapi.azurapikotlin.internal.json.Takao
10
10
import com.github.azurapi.azurapikotlin.internal.utils.info.AtagoInfo
11
- import java.util.stream.Collectors
12
11
13
12
/* *
14
13
* API class
@@ -47,8 +46,8 @@ object Atago {
47
46
* @param id id of the ship
48
47
*/
49
48
fun getShipById (id : String , caseSensitive : Boolean = false): Ship {
50
- val formattedId = if (caseSensitive) id.toLowerCase() else id
51
- return (if (caseSensitive) database.shipsById.mapKeys { it.key.toLowerCase() } else
49
+ val formattedId = if (! caseSensitive) id.toLowerCase() else id
50
+ return (if (! caseSensitive) database.shipsById.mapKeys { it.key.toLowerCase() } else
52
51
database.shipsById)[formattedId] ? : throw ShipNotFoundException (" Could not find ship with id: $id " )
53
52
}
54
53
@@ -58,7 +57,7 @@ object Atago {
58
57
* Get list of all ships
59
58
*/
60
59
fun getAllShips (): List <Ship > {
61
- return database.shipsById.values.stream().collect( Collectors . toList() )
60
+ return database.shipsById.values.toList()
62
61
}
63
62
64
63
/* *
Original file line number Diff line number Diff line change @@ -92,23 +92,27 @@ internal class Takao {
92
92
* @param search
93
93
*/
94
94
fun findShip (search : String , lang : Lang ): Ship ? {
95
- val cosine = Cosine ()
96
- var bestScore = 0.0
97
- var result: Ship ? = null
98
95
val databaseLang = when (lang) {
99
96
Lang .EN -> shipsByEnName
100
97
Lang .CN -> shipsByCnName
101
98
Lang .JP -> shipsByJpName
102
99
Lang .KR -> shipsByKrName
103
100
Lang .ANY -> shipsByEnName + shipsByCnName + shipsByJpName + shipsByKrName
104
101
}
105
- for ((name, ship) in databaseLang.entries) {
106
- val score = cosine.similarity(search.toLowerCase(), name.toLowerCase())
107
- if (score > bestScore) {
108
- result = ship
109
- bestScore = score
102
+ return if (databaseLang.containsKey(search)) {
103
+ databaseLang[search]
104
+ } else {
105
+ val cosine = Cosine ()
106
+ var bestScore = 0.0
107
+ var result: Ship ? = null
108
+ for ((name, ship) in databaseLang.entries) {
109
+ val score = cosine.similarity(search.toLowerCase(), name.toLowerCase())
110
+ if (score > bestScore) {
111
+ result = ship
112
+ bestScore = score
113
+ }
110
114
}
115
+ result
111
116
}
112
- return result
113
117
}
114
118
}
Original file line number Diff line number Diff line change @@ -4,5 +4,5 @@ package com.github.azurapi.azurapikotlin.internal.utils.info
4
4
* API info
5
5
*/
6
6
object AtagoInfo {
7
- const val VERSION = " 2.0.1 "
7
+ const val VERSION = " 3.1.3 "
8
8
}
You can’t perform that action at this time.
0 commit comments