Text Language Detection Function

  • Share this:

Code introduction


This function is used to detect the language type of a text. It takes a string argument and returns the language code of the text.


Technology Stack : TextBlob

Code Type : Function

Code Difficulty : Intermediate


                
                    
def detect_language(text):
    from textblob import TextBlob
    
    blob = TextBlob(text)
    language = blob.detect_language()
    return language                
              
Tags: