global alab_cnt
    global total_ifield

    for v in viewHierarchy.getOrdered():
        if v.is_edit_text():
            total_ifield += 1
            if v.annotatedPrivacyTag is not None:
                aprivtag_cnt += 1
            if v.annotatedLabelCounter is not None:
                alab_cnt += 1


#            if v.suporLabelCounter != v.annotatedLabelCounter:
#
#
#            if v.suporLabelCounter != v.annotatedLabelCounter:
#
#
#                suporLabelCounter
#
#                annotatedPrivacyTag
#                annotatedLabelCounter

if __name__ == '__main__':
    layout_files = getLayoutFiles()
    for apk in layout_files:
        viewHierarchy = lp.parseXmlFile(apk)
        trav(viewHierarchy)

    print aprivtag_cnt, alab_cnt, total_ifield
Exemple #2
0
	#Stopwords
	stopwords = preprocessor.load_stop_words()
	stopwords.update("number_value_example")
	# Substitution terms
	pattern,subs = readTerms()

	suporFlag = (sys.argv[1] == "supor") if len(sys.argv) >= 2 else False

	print "Running UiRef" if not suporFlag else "Running SUPOR"
	layout_files = getLayoutFiles()
	for apk in layout_files:
		with codecs.open(LOGFILE, 'a', 'utf-8') as logoutfile:
			logoutfile.write(apk)
			logoutfile.write('\n')

		try:
			viewHierarchy = layoutParser.parseXmlFile(apk)
		except:
			continue
		resVals = resolveLayout(apk,viewHierarchy, sensitiveTerms, stopwords, pattern, subs, suporFlag)
		if len(resVals) > 0:
			print resVals
		if suporFlag:
			resolveSUPOR(apk, resVals)
		else:
			disambiguate(apk, resVals)

	#Resolved by hint(92820), resolved by label(85940), resolved by text(11890)
	print "Resolved by hint(%d), resolved by label(%d), resolved by text(%d)" % (resolvedByHint, resolvedByLabel, resolvedByText)
	print suporIncorrectLabRes,"/",suporIncorrectLabResTotal, "-- no res ", suporIncorrectLabNoRes
Exemple #3
0
#!/usr/bin/env python

import parse_layout as layoutParser

cntDict = {}

for line in open('EVAL_AMBIG_TERM_RES_PER_LAYOUT.csv', 'rb'):
    splitLine = line.strip().split(',')
    if splitLine[0].startswith('RESOLVED_'):
        viewHierarchy = layoutParser.parseXmlFile(splitLine[1])
        for v in viewHierarchy.getOrdered():
            if v.is_input_field() and v.is_edit_text(
            ) and v.counter == splitLine[2]:
                if splitLine[3] not in cntDict:
                    cntDict[splitLine[3]] = [0, 0, 0]
                cntDict[splitLine[3]][2] += 1
                if v.annotatedPrivacyTag is not None:
                    cntDict[splitLine[3]][0] += 1
                    print '%s,%s' % (
                        v.annotatedPrivacyTag,
                        line.strip(),
                    )
                else:
                    cntDict[splitLine[3]][1] += 1

for key in cntDict:
    print key, cntDict[key]