Skip to content

Instantly share code, notes, and snippets.

View kajornsakp's full-sized avatar
:shipit:

Kajornsak Peerapathananont kajornsakp

:shipit:
View GitHub Profile
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.ml.naturallanguage.FirebaseNaturalLanguage
import com.google.firebase.ml.naturallanguage.languageid.FirebaseLanguageIdentification
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
private val languageIdentification: FirebaseLanguageIdentification by lazy {
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.ml.naturallanguage.FirebaseNaturalLanguage
import com.google.firebase.ml.naturallanguage.languageid.FirebaseLanguageIdentification
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
private val languageIdentification: FirebaseLanguageIdentification by lazy {
FirebaseNaturalLanguage.getInstance().languageIdentification
/** An identified language for the given input text. */
NS_SWIFT_NAME(IdentifiedLanguage)
@interface FIRIdentifiedLanguage : NSObject
/** The BCP-47 language code for the language. */
@property(nonatomic, readonly, copy) NSString *languageCode;
/** The confidence score of the language. */
@property(nonatomic, readonly) float confidence;
@kajornsakp
kajornsakp / FIRLanguageIdentification.h
Created April 15, 2019 16:35
Identify possible languages
/**
* Identifies possible languages for the given text.
*
* @param text The input text to use for identifying the language. Inputs longer than 200 characters
* are truncated to 200 characters, as longer input does not improve the detection accuracy.
* @param completion Handler to call back on the main queue with identified languages or error.
*/
- (void)identifyPossibleLanguagesForText:(NSString *)text
completion:(FIRIdentifyPossibleLanguagesCallback)completion
NS_SWIFT_NAME(identifyPossibleLanguages(for:completion:));
@kajornsakp
kajornsakp / FIRLanguageIdentification.h
Created April 15, 2019 16:28
FIRIdentifyLanguageCallback
/**
* A block that handles a language identification result.
*
* @param languageCode The identified language code for the text, `FIRMLKitUndeterminedLanguageCode`
* if no language was identified or `nil` if there was an error.
* @param error The error or `nil`.
*/
typedef void (^FIRIdentifyLanguageCallback)(NSString *_Nullable languageCode,
NSError *_Nullable error)
NS_SWIFT_NAME(IdentifyLanguageCallback);
@kajornsakp
kajornsakp / FIRLanguageIdentification.h
Created April 15, 2019 16:19
Identify language (obj-c)
/**
* Identifies the main language for the given text.
*
* @param text The input text to use for identifying the language. Inputs longer than 200 characters
* are truncated to 200 characters, as longer input does not improve the detection accuracy.
* @param completion Handler to call back on the main queue with the identified language code or
* error.
*/
- (void)identifyLanguageForText:(NSString *)text
completion:(FIRIdentifyLanguageCallback)completion
@kajornsakp
kajornsakp / build.gradle
Last active April 14, 2019 10:08
Language Identification dependencies
implementation 'com.google.firebase:firebase-ml-natural-language:18.2.0'
implementation 'com.google.firebase:firebase-ml-natural-language-language-id-model:18.0.3'
// See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
// for Dialogflow fulfillment library docs, samples, and to report issues
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Payload} = require('dialogflow-fulfillment');
const admin = require("firebase-admin");
admin.initializeApp({
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
// Device Name: Maximum 30 bytes
#define DEVICE_NAME "LINE Things Trial ESP32"
// User service UUID: Change this to your generated service UUID
#define USER_SERVICE_UUID {serviceUUID}"
[
{
"label": "4",
"title": "Surprisingly delightful",
"text": "This is a fast read filled with unexpected humour and profound insights into the art of politics and policy. In brief, it is sly, wry, and wise.",
},
{
"label": "2",
"title": "Works, but not as advertised",
"text": "I bought one of these chargers..the instructions say the lights stay on while the battery charges...true. The instructions doNT say the lights turn off when its done. Which is also true. 24 hours of charging and the lights stay on. I returned it thinking I had a bad unit.The new one did the same thing. I just kept it since it does charge...but the lights are useless since they seem to always stay on. It's a \"backup\" charger for when I manage to drain all my AAs but I wouldn't want this as my only charger.",