<commit_before>####
#### Steps for operating on the various term enrichment engines and
#### their results.
####

from behave import *
from selenium.webdriver.support.ui import Select

@given('I input the following text into the RTE input box')
def step_impl(context):
    input_box_text = context.text
    webelt = context.browser.find_element_by_id('rte_input')
    webelt.send_keys(input_box_text)

@given('I select "{results_format}" for the results')
def step_impl(context, results_format):
    select = Select(context.browser.find_element_by_id('rte_format'))
    select.select_by_visible_text(results_format)

@when('I submit the RTE form')
def step_impl(context):
    xp = "/html/body/div[2]/div[4]/div/div/form/div[2]/button"
    webelt = context.browser.find_element_by_xpath(xp)
    webelt.click()<commit_msg>make TE unit tests work for both 2.1.x and 2.2.x; work on #171<commit_after>####
#### Steps for operating on the various term enrichment engines and
#### their results.
####

from behave import *
from selenium.webdriver.support.ui import Select

@given('I input the following text into the RTE input box')
def step_impl(context):
    input_box_text = context.text
    webelt = context.browser.find_element_by_id('rte_input')
    webelt.send_keys(input_box_text)

@given('I select "{results_format}" for the results')
def step_impl(context, results_format):
    select = Select(context.browser.find_element_by_id('rte_format'))
    select.select_by_visible_text(results_format)

@when('I submit the RTE form')
def step_impl(context):

    ## Current 2.2.x location.
    xp_22x = "/html/body/div[2]/div[4]/div/div/form/div[2]/button"
    ## Current 2.1.x location.   
    xp_21x = "/html/body/div[2]/div[3]/div/div/form/div[2]/button"

    ## Try them both, starting with 2.2.x
    okay_p = False
    webelt = None
    try:
        webelt = context.browser.find_element_by_xpath(xp_22x)
        okay_p = True
    except:
        pass
    if not okay_p:
        try:
            webelt = context.browser.find_element_by_xpath(xp_21x)
            okay_p = True
        except:
            pass

    ## If everything is alright, click on it.
    if okay_p and webelt:
        webelt.click()
    else:
        assert True is False
{'fraction_non_alphanumeric': 0.11809269162210338, 'fraction_numerical': 0.013368983957219251, 'mean_word_length': 3.5816326530612246, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1547126', 'n_tokens_mistral': 766, 'n_tokens_neox': 736, 'n_words': 182}