summaryrefslogtreecommitdiffstats
path: root/silpa/utils
diff options
context:
space:
mode:
authorSanthosh Thottingal <santhosh.thottingal@gmail.com>2009-03-29 17:59:40 +0530
committerSanthosh Thottingal <santhosh.thottingal@gmail.com>2009-03-29 17:59:40 +0530
commitc5368252e3091368ae55475757ed3134d6f84249 (patch)
tree09687b84ab042ba9d339dec9d1d92ecc377d0bac /silpa/utils
parentf37edebde2304ee0643804166bf19ffee5c9dba5 (diff)
downloadRachana.git-c5368252e3091368ae55475757ed3134d6f84249.tar.gz
Rachana.git-c5368252e3091368ae55475757ed3134d6f84249.tar.xz
Rachana.git-c5368252e3091368ae55475757ed3134d6f84249.zip
new modules
Diffstat (limited to 'silpa/utils')
-rw-r--r--silpa/utils/langdetect.py12
-rw-r--r--silpa/utils/silpautils.py35
2 files changed, 41 insertions, 6 deletions
diff --git a/silpa/utils/langdetect.py b/silpa/utils/langdetect.py
index c20ac3a..727ea6d 100644
--- a/silpa/utils/langdetect.py
+++ b/silpa/utils/langdetect.py
@@ -4,8 +4,9 @@
# Copyright © 2008 Santhosh Thottingal
# Released under the GPLV3+ license
+from common import *
-class LangDetect:
+class LangDetect(SilpaModule):
def detect_lang(self, text):
words=text.split(" ")
@@ -63,11 +64,16 @@ class LangDetect:
response=response % text
detected_lang_dict = self.detect_lang(text)
response = response+"<h2>Language Detection Results</h2></hr>"
- response = response+"<table><th><td>Word</td><td>Language</td></th>"
+ response = response+"<table class=\"table1\"><tr><th>Word</th><th>Language</th></tr>"
for key in detected_lang_dict:
response = response+"<tr><td>"+key+"</td><td>"+detected_lang_dict[key]+"</td></tr>"
response = response+"</table> "
else:
response=response % ""
return response
-
+ def get_module_name(self):
+ return "Indian Language Detector"
+ def get_info(self):
+ return "Detects the language of the given text word by word. Supports only Indian Language"
+def getInstance():
+ return LangDetect()
diff --git a/silpa/utils/silpautils.py b/silpa/utils/silpautils.py
index 486c854..02556af 100644
--- a/silpa/utils/silpautils.py
+++ b/silpa/utils/silpautils.py
@@ -1,6 +1,35 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
-
+import codecs
+def getTemplate():
+ return open(getTemplateName()).read()
+def getTemplateName():
+ return loadConfiguration()["SILPA_TEMPLATE"]
+def getCopyrightInfo():
+ return loadConfiguration()["SILPA_SITE_COPYRIGHT"]
+def getModulesList():
+ conf_dict=loadConfiguration()
+ action_dict={}
+ for item in conf_dict :
+ if(item.startswith("SILPA_ACTION.")):
+ action_dict[item.replace("SILPA_ACTION.","")]=conf_dict[item]
+ return action_dict
+def loadConfiguration():
+ conf_dict={}
+ conffile = codecs. open("silpa.conf",encoding='utf-8', errors='ignore')
+ while 1:
+ text = unicode( conffile.readline())
+ if text == "":
+ break
+ line = text.split("#")[0].strip()
+ if(line == ""):
+ continue
+ try:
+ lhs = line.split("=") [ 0 ]
+ rhs = line.split("=") [ 1 ]
+ conf_dict[lhs]=rhs
+ except:
+ pass
+ return conf_dict
if __name__ == '__main__':
- body=" $$SILPA_BREADCRUMB$$ "
- print body.replace("$$SILPA_BREADCRUMB$$","hi")
+ print getModulesList()