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 Slide

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

    View 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 Slide

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

    ಈ࡞͢Δ

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  12. DEMO

    View Slide

  13. 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 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()
    findViewById(R.id.result).text =
    textLanguage.toString()
    }

    View Slide

  15. 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 Slide

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

    View Slide

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

    View Slide

  18. ಠࣗ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 Slide

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

    View Slide

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

    View Slide

  21. Thanks!

    View Slide