Example #1
0
from django.utils import translation
from django.utils.translation import get_language_info
from django.utils.datastructures import SortedDict

## either append the path of alfanous API as:
from wui.templatetags.languages import my_get_language_info

path.insert(0, "../../src")  ## a relative path, development mode
path.append("alfanous.egg/alfanous")  ## an egg, portable
path.append(
    "/home/alfanous/alfanous-django/src/")  ## absolute  path, server mode

from alfanous.Outputs import Raw

# load the search engine, use default paths
RAWoutput = Raw()


def control_access(request):
    """ Controling access to  the API """
    #print request.META["REMOTE_ADDR"]
    #print request.META["REMOTE_HOST"]
    #print request.META["QUERY_STRING"]
    #print request.META["HTTP_REFERER"]
    #print "is ajax?", request.is_ajax()
    return True


def jos2(request):
    """ JSON Output System II """
    control_access(request)
Example #2
0
def get_language_from_config():
    config = ConfigObj(CONFIGPATH + "/config.ini", encoding="utf-8")
    if config.has_key("options"):
        return config["options"]["language"] if config["options"].has_key(
            "language") else ""
    else:
        return ""


lang = get_language_from_config()
os.environ['LANGUAGE'] = lang
os.environ['LANG'] = lang

# Load Alfanous engi
RAWoutput = Raw()  # default paths

SAJDA_TYPE = {u"مستحبة": _(u"recommended"), u"واجبة": _(u"obliged")}

## Some functions
relate = lambda query, filter, index: "( " + unicode(query) + " ) " + RELATIONS[
    index
] + " ( " + filter + " ) " if index > 1 else filter if index == 1 else unicode(
    query) + " " + filter


class QUI(Ui_MainWindow):
    """ the main UI """
    def __init__(self):
        self.currentQuery = 0
        self.Queries = []
Example #3
0
##     along with this program.  If not, see <http://www.gnu.org/licenses/>.

'''
a console interface for the API.

TODO show RAW|JSON | BEST-presentation format
TODO __file__ to use resources and indexes integrated with Alfanous Module
'''

import sys
import json
from argparse import ArgumentParser

from alfanous.Outputs import Raw

RAWoutput = Raw() #use default paths

INFORMATION = RAWoutput.do( {"action":"show", "query":"information" } )["show"]["information"]
DOMAINS = RAWoutput.do( {"action":"show", "query":"domains" } )["show"]["domains"]
HELPMESSAGES = RAWoutput.do( {"action":"show", "query":"help_messages" } )["show"]["help_messages"]

arg_parser = ArgumentParser( 
                              description = INFORMATION["description"],
                              prog = 'alfanous-console',
                              version = '%(prog)s ' + INFORMATION["version"],
                              usage = sys.argv[0] + " [flags]"
                            )

# add arguments
arg_parser.add_argument( "-a", "--action", dest = "action", type = str , choices = DOMAINS["action"], help = HELPMESSAGES["action"] )
arg_parser.add_argument( "-q", "--query", dest = "query", type = str  , help = HELPMESSAGES["query"] )
Example #4
0
"""


# import Output object
from alfanous.Outputs import Raw

# import default Paths
from alfanous.Data import Paths

# Initialize search engines
RAWoutput = Raw(
                    QSE_index = Paths.QSE_INDEX, # Quranic Main index path
                    TSE_index = Paths.TSE_INDEX, # Translations index path
                    WSE_index = Paths.WSE_INDEX, # Quranic words index path
                    Recitations_list_file = Paths.RECITATIONS_LIST_FILE,
                    Translations_list_file = Paths.TRANSLATIONS_LIST_FILE ,
                    Hints_file = Paths.HINTS_FILE,
                    Stats_file = Paths.STATS_FILE,
                    Information_file = Paths.INFORMATION_FILE
                )

## prepare a suggestion query
suggest_flags = {
            "action":"suggest",
            "query": "ابراهيم"
            }

results = RAWoutput.do( suggest_flags )

print "number of missed words", len(results["suggest"])
Example #5
0
##     You should have received a copy of the GNU Affero General Public License
##     along with this program.  If not, see <http://www.gnu.org/licenses/>.
'''
a console interface for the API.

TODO show RAW|JSON | BEST-presentation format
TODO __file__ to use resources and indexes integrated with Alfanous Module
'''

import sys
import json
from argparse import ArgumentParser

from alfanous.Outputs import Raw

RAWoutput = Raw()  #use default paths

INFORMATION = RAWoutput.do({
    "action": "show",
    "query": "information"
})["show"]["information"]
DOMAINS = RAWoutput.do({
    "action": "show",
    "query": "domains"
})["show"]["domains"]
HELPMESSAGES = RAWoutput.do({
    "action": "show",
    "query": "help_messages"
})["show"]["help_messages"]

arg_parser = ArgumentParser(description=INFORMATION["description"],