SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot m0h's Avatar
    Join Date
    Sep 2001
    Location
    Cairo, Egypt
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Knowing the language of a text?

    Hello every one!
    Is there a way to find out the language of a text or at least find out if it is english or not

    Thanx
    - m0h

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's an interesting one and I can't think of a way. I will be interested if anyone can do this

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  3. #3
    SitePoint Zealot m0h's Avatar
    Join Date
    Sep 2001
    Location
    Cairo, Egypt
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I have a small idea but I'm not sure if it is going to work or not, my idea is making a list of all english characters and then check the text to see if it has other characters that are not in the list, If so it is not english, what do u think?
    - m0h

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I was thinking is that you could try and match the text with a list of common words for each language, for example me, he, she, the for English. This would probably take you ages and I don't know you accurate it would be

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  5. #5
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think so... lol you could try that, but spanish typed on an an american keyboard wouldn't have any of the special characters, yet it wouldn't be english either!

  6. #6
    purple monkey dishwasher scoates's Avatar
    Join Date
    Nov 2001
    Location
    Montreal
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's some code...
    it's cheap, and not entirely accurate, but it works "most" of the time..

    PHP Code:
    <?php

    $text1 
    "a c'est de la texte";
    $text2 "this is some text";

    echo 
    "\$text1: ". ( ereg("[(c')]"$text1) ? "non-english" "english") ."<br>\n";
    echo 
    "\$text2: ". ( ereg("[(c')]"$text2) ? "non-english" "english") ."<br>\n";

    ?>
    output:
    Code:
    $text1: non-english
    $text2: english
    S

  7. #7
    SitePoint Zealot m0h's Avatar
    Join Date
    Sep 2001
    Location
    Cairo, Egypt
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx every one
    Thanx scoates you code works very good for me
    till know it pathed all the test I made

    Thanx again
    - m0h

  8. #8
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Snoozy
    spanish typed on an an american keyboard wouldn't have any of the special characters
    There are ways around this

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •