<jupyter_start><jupyter_text>Setup<jupyter_code># @markdown Machine setup

# Install java 11
!sudo DEBIAN_FRONTEND=noninteractive apt-get install -qq git openjdk-11-jdk > /dev/null

# Install python 3.7 and pip
!sudo DEBIAN_FRONTEND=noninteractive apt-get install -qq python3.7 python3.7-dev python3.7-venv python3-pip > /dev/null
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 > /dev/null
!python3 -m pip install -q --upgrade pip > /dev/null

# Install pipenv (i.e. a better python package manager).
!pip3 install pipenv -qq > /dev/null
%env PIPENV_QUIET 1
%env PIPENV_VENV_IN_PROJECT 1
%env PIPENV_SKIP_LOCK 1

from IPython.display import clear_output
clear_output()
# @markdown Code setup

# Clone the project and cd into it
!git clone -q --branch master https://github.com/simonepri/varname-seq2seq code
%cd -q code

# Install dependencies
!pipenv install > /dev/null
# @markdown Download the model
MODEL_TYPE = "java-lstm-1-256-256-dtf-lrs-obf"  # @param ["java-lstm-1-256-256-dtf-lrs-obf", "java-lstm-1-256-256-dtf-lrs"]
!pipenv run bin src/bin/download_data.py --file-name {MODEL_TYPE}.tgz --data-path data/models/{MODEL_TYPE} > /dev/null<jupyter_output><empty_output><jupyter_text>Input code<jupyter_code>!mkdir -p demo
CLASS_NAME = "Test" # @param {type: "string"}
%%writefile demo/{CLASS_NAME}.java
public class Test {
  String d;
  Test(String a, String b) {
    int c = 42;
    int d = b.length();
    this.d = a;
    for (int i = 0; i < c; i++) {
      System.out.println(d + " -> " + c);
    }
  }
}<jupyter_output><empty_output><jupyter_text>Model output<jupyter_code>OBFUSCATE = True # @param {type: "boolean"}
if OBFUSCATE:
    !pipenv run bin -W ignore src/bin/run_e2e.py \
      --model-path data/models/{MODEL_TYPE} \
      --file-path demo/{CLASS_NAME}.java \
      --obfuscate
else:
  !pipenv run bin -W ignore src/bin/run_e2e.py \
      --model-path data/models/{MODEL_TYPE} \
      --file-path demo/{CLASS_NAME}.java<jupyter_output>⚠️  | 001.001 | a → d
⚠️  | 001.002 | b → value
⚠️  | 001.003 | c → d
⚠️  | 001.004 | d → i
✔️  | 001.005 | i
{'fraction_non_alphanumeric': 0.1457142857142857, 'fraction_numerical': 0.0380952380952381, 'mean_word_length': 3.470212765957447, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 20, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '471898', 'license': 'MIT', 'n_tokens_mistral': 890, 'n_tokens_neox': 846, 'n_words': 204, 'path': 'examples/predict_java.ipynb', 'repo_name': 'simonepri/varname-transformers', 'size': '2100'}