Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TextClassifier

 TextClassifier

TextClassifier

TextClassifier-Sample
https://github.com/operando/TextClassifier-Sample

Shibuya.apk #34 - Report from Google I/O 2019
https://shibuya-apk.connpass.com/event/128668/

operandoOS

May 17, 2019
Tweet

More Decks by operandoOS

Other Decks in Technology

Transcript

  1. TextClassifier
    Shibuya.apk #34

    View full-size slide

  2. TextClassifier
    • Oreo(API level 26)͔Β௥Ճ͞ΕͨAPI
    • ςΩετ෼ྨثͷͨΊͷAPI
    • ෼ྨʹ͸ػցֶशͷϞσϧ͕࢖ΘΕ͍ͯΔ

    View full-size slide

  3. Smart Linkify
    • Android P͔Β
    • TextClassifierΛར༻ͯ͠Δ
    • https://developer.android.com/about/versions/pie/
    android-9.0#text
    • Smart Text SelectionͷਐԽ൛ʁ
    • https://www.youtube.com/watch?
    v=Y2VF8tmLFHw&t=4832

    View full-size slide

  4. Smart Linkify
    • TextViewͱWebViewͰબ୒ΛONʹ͢Ε͹
    TextClassifierΛ࢖༻ͨ͠Smart Linkify͕

    ಈ࡞͢Δ

    View full-size slide

  5. Smart Linkifyͷৄࡉ
    • The Machine Learning Behind Android
    Smart Linkify
    • https://ai.googleblog.com/2018/08/the-
    machine-learning-behind-android.html

    View full-size slide

  6. TextClassifierͷػೳ
    • TextClassification
    • TextLinks
    • TextSelection
    • TextLanguage(Q API)
    • ConversationActions(Q API)

    View full-size slide

  7. TextClassification
    • ࢦఆ͞ΕͨςΩετΛ෼ྨ͠ɺ෼ྨ͞Εͨς
    ΩετΛॲཧ͢ΔͨΊͷ΢ΟδΣοτΛੜ੒
    ͢ΔͨΊʹ࢖༻Ͱ͖ΔTextClassification
    objectΛฦ͢

    View full-size slide

  8. TextLinks
    • ϦϯΫʹ஫ऍΛ෇͚ΔͨΊʹςΩετʹద༻
    ͞ΕΔTextLinksΛੜ੒

    View full-size slide

  9. TextSelection
    • ςΩετબ୒ͷ։࢝ҐஔͱऴྃҐஔɺೝࣝ͞
    Ε͍ͯΔΤϯςΟςΟͷछྨɺ͓ΑͼͦΕΒ
    ʹؔ࿈͢Δ৴པείΞΛฦ͢

    View full-size slide

  10. TextLanguage
    • ࢦఆ͞ΕͨςΩετͷݴޠΛݕग़

    View full-size slide

  11. ConversationActions
    • ༩͑ΒΕͨձ࿩ʹैͬͯΞΫγϣϯͷϦετ
    ΛఏҊ

    View full-size slide

  12. TextSelection
    GlobalScope.launch(Dispatchers.Main) {
    val tcm =
    getSystemService(TextClassificationManager::class.java)
    val ts: TextSelection = async {
    tcm.textClassifier.suggestSelection(
    TextSelection.Request.Builder(
    "GoogleͷαΠτURL:https://google.com"
    ,21,32).build())
    }.await()
    findViewById(R.id.result).text = ts.toString()
    }

    View full-size slide

  13. TextLanguage
    GlobalScope.launch {
    val tcm = getSystemService(
    TextClassificationManager::class.java)
    val tlr = TextLanguage.Request.Builder(text).build()
    val textLanguage = async
    { tcm.textClassifier.detectLanguage(tlr) }.await()
    findViewById(R.id.result).text =
    textLanguage.toString()
    }

    View full-size slide

  14. TextLanguage
    GlobalScope.launch {
    val tcm = getSystemService
    (TextClassificationManager::class.java)
    val tlr = TextLanguage.Request.Builder(text).build()
    val textLanguage = async
    { tcm.textClassifier.detectLanguage(tlr) }.await()
    val s = textLanguage.getConfidenceScore(
    ULocale.JAPANESE)
    }

    View full-size slide

  15. TextClassifier Sample
    https://github.com/operando/
    TextClassifier-Sample

    View full-size slide

  16. AndroidX Textclassifier
    https://developer.android.com/
    jetpack/androidx/releases/
    textclassifier

    View full-size slide

  17. ಠࣗTextClassifierΛ࣮૷ͯ͠Δྫ
    • https://search.siprop.org/android-9.0.0_r1.0/xref/
    packages/apps/DocumentsUI/src/com/android/
    documentsui/inspector/
    GpsCoordinatesTextClassifier.java
    • TextView#setTextClassifierͰηοτ
    • https://developer.android.com/reference/android/
    widget/
    TextView#setTextClassifier(android.view.textclassifier.
    TextClassifier)

    View full-size slide

  18. Implementing Text Classification
    • OEMͰ࢖͏Ϟσϧͱ͔ΛมߋͰ͖Δͷ͔ͳʁ
    • ඞཁʹԠ͡ͰϞσϧͷߋ৽ͱ͔΋Ͱ͖ͦ͏ʁ
    • https://source.android.com/devices/tech/
    display/textclassifier

    View full-size slide

  19. TextClassifierΛѻͬͨϒϩά
    • https://blog.stylingandroid.com/
    textclassification-part-1/
    • https://blog.stylingandroid.com/
    textclassification-part-2/
    • https://blog.stylingandroid.com/
    textclassification-part-3/

    View full-size slide