MCPcopy Create free account
hub / github.com/a7medev/react-native-ml-kit / App

Function App

identify-languages/example/App.js:5–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import IdentifyLanguages from '@react-native-ml-kit/identify-languages';
4
5const App = () => {
6 const [text, setText] = useState('');
7 const [lang, setLang] = useState('');
8
9 useEffect(() => {
10 IdentifyLanguages.identify(text).then(setLang).catch(console.error);
11 IdentifyLanguages.identifyPossible(text)
12 .then(identifiedLangs => {
13 console.log(identifiedLangs);
14 })
15 .catch(console.error);
16 }, [text]);
17
18 return (
19 <View style={styles.container}>
20 <Text style={styles.heading}>Enter text to detect language</Text>
21 <TextInput
22 placeholder="Enter text here"
23 multiline
24 textAlignVertical="top"
25 style={styles.input}
26 value={text}
27 onChangeText={_text => setText(_text)}
28 />
29 {lang ? (
30 <Text style={styles.heading}>Language Code is: {lang}</Text>
31 ) : null}
32 </View>
33 );
34};
35
36const styles = StyleSheet.create({
37 container: {

Callers

nothing calls this directly

Calls 2

identifyMethod · 0.80
identifyPossibleMethod · 0.80

Tested by

no test coverage detected