예제 #1
0
파일: app.py 프로젝트: Xion/visual-camxes
def index():
    text = request.args.get('text', "coi pilno mi'e camxes")
    try:
        ast = camxes.parse(text)
        grammatical = camxes.isgrammatical(text)
    except:
        return redirect(url_for('index'))
    if 'json' in request.args:
        return jsonify(html=render_template('box.html', dict(text=text, ast=ast)),
            grammatical=grammatical)
    return render_response('index.html',
        dict(ast=ast, text=text, grammatical=grammatical))
예제 #2
0
def index():
    text = request.args.get('text', "coi pilno mi'e camxes")
    try:
        ast = camxes.parse(text)
        grammatical = camxes.isgrammatical(text)
    except:
        return redirect(url_for('index'))
    if 'json' in request.args:
        return jsonify(html=render_template('box.html', dict(text=text,
                                                             ast=ast)),
                       grammatical=grammatical)
    return render_response('index.html',
                           dict(ast=ast, text=text, grammatical=grammatical))
예제 #3
0
def getEnglishTranslation(sentence):
    """parse a lojban sentence
      return the english translation"""

    # get a list of all the names
    names = [str(e) for e in re.findall(r"\.[^\s]*\.", sentence)]

    # replace all occurences with "ko"
    sentence = re.sub(r"\.[^\s]*\.", "ko", sentence)

    # make a parse tree
    rootNode = camxes.parse(sentence)

    if tree:
        print rootNode

    return translateSentence(rootNode, names=names)
예제 #4
0
def getEnglishTranslation( sentence ):
   """parse a lojban sentence
      return the english translation"""

   
   # get a list of all the names
   names = [ str(e) for  e in re.findall( r"\.[^\s]*\.", sentence ) ]
   
   

   # replace all occurences with "ko"
   sentence = re.sub( r"\.[^\s]*\.", "ko", sentence)
   
    
   # make a parse tree
   rootNode = camxes.parse( sentence )
    
   if tree:
      print rootNode
   
   
   return translateSentence( rootNode, names=names ) 
예제 #5
0
def parse_tree():
    yield camxes.parse("coi rodo mi cipra loka na cfila la camxes")
예제 #6
0
def parse_trees_from_outer_space():
    yield camxes.parse("coi rodo!"), camxes.parse("coi rodo!", spaces=True)
예제 #7
0
import sys
from camxes import parse, isgrammatical

print parse(sys.argv[1])
print
if not isgrammatical(sys.argv[1]):
    print 'not',
print 'grammatical:', sys.argv[1]
예제 #8
0
def parse_trees_from_outer_space():
    yield camxes.parse("coi rodo!"), camxes.parse("coi rodo!", spaces=True)
예제 #9
0
def parse_tree():
    yield camxes.parse("coi rodo mi cipra loka na cfila la camxes")