generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mikrise2
committed
Oct 10, 2023
1 parent
9fe1142
commit 82a8f92
Showing
29 changed files
with
274 additions
and
136 deletions.
There are no files selected for viewing
This file contains 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 contains 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
29 changes: 29 additions & 0 deletions
29
ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/Emoji.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.jetbrains.research.tasktracker.config.emoji | ||
|
||
import com.intellij.openapi.util.IconLoader | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.Transient | ||
import javax.swing.Icon | ||
|
||
@Serializable | ||
data class Emoji( | ||
val modelPosition: Int, | ||
val name: String, | ||
private val affirmDescriptions: List<String>, | ||
private val adviceDescriptions: List<String> = emptyList() | ||
) { | ||
private val iconName: String? = null | ||
private val modalWindowIconName: String? = null | ||
|
||
@Transient | ||
val icon: Icon? = iconName?.let { IconLoader.getIcon(it, Emoji::class.java) } | ||
|
||
@Transient | ||
val modalWindowIcon: Icon? = modalWindowIconName?.let { IconLoader.getIcon(it, Emoji::class.java) } | ||
|
||
val randomAffirmDescription | ||
get() = affirmDescriptions.random() | ||
|
||
val randomAdviceDescription | ||
get() = adviceDescriptions.random() | ||
} |
25 changes: 25 additions & 0 deletions
25
ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/EmojiConfig.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.jetbrains.research.tasktracker.config.emoji | ||
|
||
import kotlinx.serialization.Serializable | ||
import org.jetbrains.research.tasktracker.config.BaseConfig | ||
import org.jetbrains.research.tasktracker.config.YamlConfigLoadStrategy | ||
import org.jetbrains.research.tasktracker.handler.BaseHandler | ||
import org.jetbrains.research.tasktracker.handler.emoji.EmojiHandler | ||
import java.io.File | ||
|
||
@Serializable | ||
data class EmojiConfig( | ||
val emojis: List<Emoji> | ||
) : BaseConfig { | ||
override val configName: String | ||
get() = "emoji" | ||
|
||
override fun buildHandler(): BaseHandler = EmojiHandler(this) | ||
|
||
companion object { | ||
const val CONFIG_FILE_PREFIX: String = "emoji" | ||
|
||
fun buildConfig(configFile: File): EmojiConfig = | ||
YamlConfigLoadStrategy.load(configFile.readText(), serializer()) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/handler/emoji/EmojiHandler.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.jetbrains.research.tasktracker.handler.emoji | ||
|
||
import com.intellij.openapi.project.Project | ||
import org.jetbrains.research.tasktracker.config.BaseConfig | ||
import org.jetbrains.research.tasktracker.handler.BaseHandler | ||
|
||
class EmojiHandler(override val config: BaseConfig) : BaseHandler { | ||
|
||
override fun setup(project: Project) { | ||
// TODO("Setup emojis according to the config") | ||
} | ||
} |
110 changes: 55 additions & 55 deletions
110
ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/modelInference/EmoClient.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
|
||
import io.ktor.client.* | ||
import io.ktor.client.call.* | ||
import io.ktor.client.engine.cio.* | ||
import io.ktor.client.plugins.contentnegotiation.* | ||
import io.ktor.client.request.* | ||
import io.ktor.http.* | ||
import io.ktor.serialization.kotlinx.json.* | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.json.Json | ||
import org.jetbrains.research.tasktracker.modelInference.EmoPrediction | ||
import org.jetbrains.research.tasktracker.modelInference.EmoPredictor | ||
import org.jetbrains.research.tasktracker.modelInference.prepareImage | ||
import org.opencv.core.Mat | ||
|
||
@Serializable | ||
data class ImageData(val image: List<List<Double>>) | ||
class EmoClient(private var serverUrl: String = "http://localhost:5230/predict") : EmoPredictor { | ||
|
||
private val client = HttpClient(CIO) { | ||
install(ContentNegotiation) { | ||
json( | ||
Json { | ||
prettyPrint = true | ||
isLenient = true | ||
}, | ||
) | ||
} | ||
} | ||
|
||
override suspend fun predict(image: Mat): EmoPrediction { | ||
val prepImage = prepareImage(image) | ||
|
||
val imageList = mutableListOf<List<Double>>() | ||
for (row in 0 until prepImage.rows()) { | ||
val rowList = mutableListOf<Double>() | ||
for (col in 0 until prepImage.cols()) { | ||
val pixelValue = prepImage.get(row, col)[0] | ||
rowList.add(pixelValue) | ||
} | ||
imageList.add(rowList) | ||
} | ||
|
||
val imageData = ImageData(imageList) | ||
|
||
val response: Map<Int, Double> = client.post(serverUrl) { | ||
contentType(ContentType.Application.Json) | ||
setBody(imageData) | ||
}.body() | ||
|
||
println("Emotion Probabilities: $response") | ||
|
||
return EmoPrediction(response) | ||
} | ||
} | ||
// | ||
//import io.ktor.client.* | ||
//import io.ktor.client.call.* | ||
//import io.ktor.client.engine.cio.* | ||
//import io.ktor.client.plugins.contentnegotiation.* | ||
//import io.ktor.client.request.* | ||
//import io.ktor.http.* | ||
//import io.ktor.serialization.kotlinx.json.* | ||
//import kotlinx.serialization.Serializable | ||
//import kotlinx.serialization.json.Json | ||
//import org.jetbrains.research.tasktracker.modelInference.EmoPrediction | ||
//import org.jetbrains.research.tasktracker.modelInference.EmoPredictor | ||
//import org.jetbrains.research.tasktracker.modelInference.prepare | ||
//import org.opencv.core.Mat | ||
// | ||
//@Serializable | ||
//data class ImageData(val image: List<List<Double>>) | ||
//class EmoClient(private var serverUrl: String = "http://localhost:5230/predict") : EmoPredictor { | ||
// | ||
// private val client = HttpClient(CIO) { | ||
// install(ContentNegotiation) { | ||
// json( | ||
// Json { | ||
// prettyPrint = true | ||
// isLenient = true | ||
// }, | ||
// ) | ||
// } | ||
// } | ||
// | ||
// override suspend fun predict(image: Mat): EmoPrediction { | ||
// val prepImage = image.prepare() | ||
// | ||
// val imageList = mutableListOf<List<Double>>() | ||
// for (row in 0 until prepImage.rows()) { | ||
// val rowList = mutableListOf<Double>() | ||
// for (col in 0 until prepImage.cols()) { | ||
// val pixelValue = prepImage.get(row, col)[0] | ||
// rowList.add(pixelValue) | ||
// } | ||
// imageList.add(rowList) | ||
// } | ||
// | ||
// val imageData = ImageData(imageList) | ||
// | ||
// val response: Map<Int, Double> = client.post(serverUrl) { | ||
// contentType(ContentType.Application.Json) | ||
// setBody(imageData) | ||
// }.body() | ||
// | ||
// println("Emotion Probabilities: $response") | ||
// | ||
// return EmoPrediction(response) | ||
// } | ||
//} |
19 changes: 12 additions & 7 deletions
19
ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/modelInference/EmoPredictor.kt
This file contains 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 contains 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 contains 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
Binary file added
BIN
+2.06 KB
...c/main/resources/org/jetbrains/research/tasktracker/config/emoji/angry_face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.12 KB
...n/resources/org/jetbrains/research/tasktracker/config/emoji/confounded_face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.91 KB
...sources/org/jetbrains/research/tasktracker/config/emoji/expressionless_face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.04 KB
...ources/org/jetbrains/research/tasktracker/config/emoji/face_with_open_mouth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.01 KB
...g/jetbrains/research/tasktracker/config/emoji/frowning_face_with_open_mouth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.26 KB
...ources/org/jetbrains/research/tasktracker/config/emoji/modal_cherry_blossom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.64 KB
...c/main/resources/org/jetbrains/research/tasktracker/config/emoji/modal_dove.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.84 KB
...esources/org/jetbrains/research/tasktracker/config/emoji/modal_folded_hands.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.6 KB
...esources/org/jetbrains/research/tasktracker/config/emoji/modal_glowing_star.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.67 KB
...urces/org/jetbrains/research/tasktracker/config/emoji/modal_leaf_fluttering.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.57 KB
...in/resources/org/jetbrains/research/tasktracker/config/emoji/modal_seedling.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.31 KB
...sources/org/jetbrains/research/tasktracker/config/emoji/modal_sun_with_face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.65 KB
.../resources/org/jetbrains/research/tasktracker/config/emoji/modal_water_wave.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.61 KB
...esources/org/jetbrains/research/tasktracker/config/emoji/modal_wrapped_gift.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.09 KB
...main/resources/org/jetbrains/research/tasktracker/config/emoji/pensive_face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.14 KB
...ain/resources/org/jetbrains/research/tasktracker/config/emoji/relieved_face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.1 KB
.../jetbrains/research/tasktracker/config/emoji/smiling_face_with_smiling_eyes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.63 KB
...ain/resources/org/jetbrains/research/tasktracker/config/emoji/sun_with_face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.