Esempio n. 1
0
def xml(num) :
	if num<=1500:
		T=xmlParser("XML_tests/treeXml1To1500/tree%d.xml" % num)
	elif num<=1900:
		T=xmlParser("XML_tests/treeXml1501To1900/tree%d.xml" % num)
	elif num>=2000 and num<=30000:
		T=xmlParser("XML_tests/treeXml2000To30000/tree%d.xml" % num)
	elif num>=30100 and num<=33300:
		T=xmlParser("XML_tests/treeXml30100To33300/tree%d.xml" % num)
Esempio n. 2
0
def par(QUE):
    trans = None;
    try:
        trans = xp.xmlParser();
        trans.xmlParseInit(QUE);
    except Exception as e:
        print(e);
Esempio n. 3
0
def main(argv):
    input_stream = FileStream(argv[1])
    lexer = xmlLexer(input_stream)
    stream = CommonTokenStream(lexer)
    parser = xmlParser(stream)
    tree = parser.s()
    listener = xmlListener()
    walker = ParseTreeWalker()
    walker.walk(listener, tree)
Esempio n. 4
0
def run(i_file,o_file):
    temp = open(i_file,'r').read()
    char_stream = antlr3.ANTLRStringStream(temp)
    lexer = xmlLexer(char_stream)
    tokens = antlr3.CommonTokenStream(lexer)
    parser = xmlParser(tokens)
    r = parser.document()
    """
    for t in parser.toks:
        res = BeautifulStoneSoup(t.getText(),convertEntities=BeautifulStoneSoup.ALL_ENTITIES)
        print res
    """

    root = r.tree
    print root.toStringTree()

    nodes = antlr3.tree.CommonTreeNodeStream(root)
    nodes.setTokenStream(tokens)
    tp = xmlTreeParser(nodes)
    tp.document()
    """
    out = open(o_file,'wb')
    pickle.dump(tp.instances,out)
    out.close()
    logger.info("Pickled data written to file %s"%o_file)
    """
    fout = codecs.open(o_file,'w',encoding="utf-8")
    fout.write(json.dumps(tp.instances))
    fout.close()
    #print(json.dumps(tp.instances))
    #pprint.pprint(tp.instances)
    temp = open(i_file,'r')
    for inst in tp.instances:
		for tok in tp.instances[inst]:
			temp.seek(tok["start"])
			text = "\"%s\" == \"%s\""%(tok["utext"], temp.read(tok["end"]-tok["start"]+1))
			logger.debug(text.decode('UTF-8'))
Esempio n. 5
0
execTimeXMLAsy=[]
execTimeXMLAsy.append(0)
execTimeGV=[]
execTimeGV.append(0)

nbIte=3
nbIteNX=5
i=1
n=0

while i<=2000 and n<=200000:
	# Premier parsing pour récupérer la structure d'arbre
	# pour déterminer le nombre de noeuds contenu
	ok=True
	if i<=1500:
		T=xmlParser("XML_tests/treeXml1To1500/tree%d.xml" % i)
	elif i<=1900:
		T=xmlParser("XML_tests/treeXml1501To1900/tree%d.xml" % i)
	elif i>=2000 and i<=30000:
		T=xmlParser("XML_tests/treeXml2000To30000/tree%d.xml" % i)
	elif i>=30100 and i<=33300:
		T=xmlParser("XML_tests/treeXml30100To33300/tree%d.xml" % i)
	else:
		ok=False
	
	if ok:
		n=T.nbNode()
		# Chercher le slot où placer n
		slot=0
		while slot<len(nbNode) and nbNode[slot]<n:
			slot+=1