Created
November 26, 2019 07:54
-
-
Save mohdsanadzakirizvi/3ab00585038ba6c17b92636734a898a5 to your computer and use it in GitHub Desktop.
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
import NaturalLanguage | |
let string1 = """ | |
Hello world, I love machine learning and I work as a Data Scientist in India. | |
機械学習で働くのが好き | |
""" | |
let string2 = " أحب العمل في التعلم الآلي" | |
// Initialize LanguageRecognizer | |
let languageRecog = NLLanguageRecognizer() | |
// find the dominant language | |
languageRecog.processString(string1) | |
print("Dominant language is: \(languageRecog.dominantLanguage?.rawValue)") | |
// identify the possible languages | |
languageRecog.processString(string2) | |
print("Possible languages are:\(languageRecog.languageHypotheses(withMaximum: 2))") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment