Software Variables
1) Write a function to print all the variable names.
2) Description: the purpose of this assignment is to understand the concreteness of software variables. Two files are needed for the project.
File description:
jasperReport2_04.txt: variable names extracted from java source code, The format of the file:
PackageNameClassNameMethodNameVarTypeVarDeclNameLine# VarUsageAtLine
net.sf.jasperreports.ant JRAntCompileTask ClassField Path src 86 [104, 106, 110, 281, 281, 321]
net.sf.jasperreports.ant JRAntCompileTask ClassField File destdir 87 [290, 290, 295, 341, 347, 347]
net.sf.jasperreports.ant JRAntCompileTask ClassField File tempdir 88 [230, 232, 302, 302, 307]
net.sf.jasperreports.ant JRAntCompileTask ClassField boolean keepjava 89 [235]
net.sf.jasperreports.ant JRAntCompileTask setSrcdir Path srcdir 102 [106, 110]
net.sf.jasperreports.ant JRAntCompileTask setDestdir File destdir 136 [138, 138
Concreteness_ratings_Brysbaert_et_al_BRM.XLSX
Tasks
Part 1: develop a java function to retrieve the concreteness of one software variable
Function name: double retrieveConretness(String aVariable)
Input: a variable declaration name (e.g. “classLoader”).
Output: the concreteness of the input variable name
1. Data processing:
a. If the variable name contains multiple words, you need to split the variable name into “words” based on Capitalization, or other symbols such as - and _.
b. Note, some variable names are the combination of multiple words. You need to
i. Split variable names based on Capitalization, or other symbols such as - and _.
ii. If every letter in a variable name is capitalized, it will be taken as one word. But you still need to split based on - or _.
c. Transfer each word into lower-case.
2. Concreteness computing:
a. For each word, find out related “Conc.M” (column 3 in Concreteness_ratings_Brysbaert_et_al_BRM.XLSX)
b. If you cannot find the same word, please assign concreteness value as 0.
c. The concreteness of a variable name is the average concreteness of the words from step 1.
Test cases:
classLoader, valueAxisLabelFont, categoryExpression, conn, fontName, ROOT_START, LINE_SPACING_SINGLE
Part 2: Save concreteness results in files
Input: jasperReport2_04.txt
Output 1: list all variable names in jasperReport2_04.txt and its frequencies in descending orders. Save it in jasperReport2_04_freq.txt. Separate with “\t” (tabs).
Format:
VariableName Frequency Concreteness
v1 99 3.0
v2 93 3.9
…
…
Output 2: read each variable name from jasperReport2_04.txt (column 4). List those variable names that are not in the first column of Concreteness_ratings_Brysbaert_et_al_BRM.XLSX. Save it in jasperReport2_04_newVariables.txt. Separate with “\t” (tabs).
VarNameNotInBRM Frequency Concreteness
v1_new 99 0.0
v2_new 93 0.0