<commit_before><?php
namespace Wurfl\VirtualCapability;

    /**
     * Copyright (c) 2012 ScientiaMobile, Inc.
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Affero General Public License as
     * published by the Free Software Foundation, either version 3 of the
     * License, or (at your option) any later version.
     *
     * Refer to the COPYING.txt file distributed with this package.
     *
     *
     * @category   WURFL
     * @package    \Wurfl\VirtualCapability\VirtualCapability
     * @copyright  ScientiaMobile, Inc.
     * @license    GNU Affero General Public License
     * @version    $id$
     */

use Wurfl\Request\GenericRequest;

/**
 * Standalone utility for deriving device capabilities from a user agent
 *
 * @package \Wurfl\VirtualCapability\VirtualCapability
 */
class UserAgentTool
{
    /**
     * Gets a device from the UA
     * @param \Wurfl\Request\GenericRequest $request
     * @return \Wurfl\VirtualCapability\Tool\Device
     */
    public function getDevice(GenericRequest $request) {
        $device = $this->assignProperties(new Tool\Device($request));
        $device->normalize();
        return $device;
    }

    /**
     * Gets a device from the UA
     * @param \Wurfl\VirtualCapability\Tool\Device $device
     * @return \Wurfl\VirtualCapability\Tool\Device
     */
    protected function assignProperties(Tool\Device $device) {
        //Is UA Android?
        if (strpos($device->device_ua, 'Android') !== false) {
            $device->os->setRegex($device->device_ua, '#Android(?: |/)(?:[0-9]\.[0-9]).+#', 'Android', 1);

            //Is Dalvik?<commit_msg>reverted change<commit_after><?php
namespace Wurfl\VirtualCapability;

    /**
     * Copyright (c) 2012 ScientiaMobile, Inc.
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Affero General Public License as
     * published by the Free Software Foundation, either version 3 of the
     * License, or (at your option) any later version.
     *
     * Refer to the COPYING.txt file distributed with this package.
     *
     *
     * @category   WURFL
     * @package    \Wurfl\VirtualCapability\VirtualCapability
     * @copyright  ScientiaMobile, Inc.
     * @license    GNU Affero General Public License
     * @version    $id$
     */

use Wurfl\Request\GenericRequest;

/**
 * Standalone utility for deriving device capabilities from a user agent
 *
 * @package \Wurfl\VirtualCapability\VirtualCapability
 */
class UserAgentTool
{
    /**
     * Gets a device from the UA
     * @param \Wurfl\Request\GenericRequest $request
     * @return \Wurfl\VirtualCapability\Tool\Device
     */
    public function getDevice(GenericRequest $request) {
        $device = $this->assignProperties(new Tool\Device($request));
        $device->normalize();
        return $device;
    }

    /**
     * Gets a device from the UA
     * @param \Wurfl\VirtualCapability\Tool\Device $device
     * @return \Wurfl\VirtualCapability\Tool\Device
     */
    protected function assignProperties(Tool\Device $device) {
        //Is UA Android?
        if (strpos($device->device_ua, 'Android') !== false) {
            $device->os->setRegex($device->device_ua, '#Android(?: |/)([0-9]\.[0-9]).+#', 'Android', 1);

            //Is Dalvik?
{'fraction_non_alphanumeric': 0.11486086441681469, 'fraction_numerical': 0.005920663114268798, 'mean_word_length': 2.6411637931034484, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '1555825', 'n_tokens_mistral': 990, 'n_tokens_neox': 973, 'n_words': 280}