Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding a sample.py

  • Loading branch information...
commit 1585da762619d5810367be085a225513ed8014b8 1 parent da47dc1
@crodas authored
Showing with 24 additions and 1 deletion.
  1. +1 −1  README.markdown
  2. +23 −0 sample.py
View
2  README.markdown
@@ -1,4 +1,4 @@
Language detector
==============================
-
+This is just another implementation of the language detector using n-gramas.
View
23 sample.py
@@ -0,0 +1,23 @@
+#encoding: iso-8859-1
+from languess import Languess
+from glob import glob
+
+def main():
+ # create the object, then load all the knowledge
+ lg = Languess()
+ klm = {}
+ for lm in glob('knowledge/*.lm'):
+ klm[ lm[10:-3] ] = [n.strip() for n in open(lm).readlines()]
+ lg.load_knowledge( klm )
+
+ # English
+ print lg.getLang("This is just a bloody text")
+ # Spanish
+ print lg.getLang("Pues esto es un texto en español")
+ # Guarani
+ print lg.getLang("Mba'eteko chera'a mba'eichapa reiko?")
+ # I just know those three langs, sorry ;)
+
+
+if __name__ == "__main__":
+ main()
Please sign in to comment.
Something went wrong with that request. Please try again.