Giter Club home page Giter Club logo

uaparser.jl's Introduction

UAParser

Build Status
Coverage Status

UAParser is a Julia port of ua-parser, which itself is a multi-language port of BrowserScope's user agent string parser. Per the README file of the main project:

"The crux of the original parser--the data collected by Steve Souders over the years--has been extracted into a separate YAML file so as to be reusable as is by implementations in other programming languages."

UAParser is a limited Julia implementation heavily influenced by the Python code from the ua-parser library.

New regexes have were retrieved from here on 2018-12-19.

UAParser API

The API for UAParser revolves around three functions: parsedevice, parseos and parseuseragent. Each function takes one argument, user_agent_string::AbstractString and returns a custom Julia type: DeviceResult, OSResult, or UAResult. The structure of each type is as follows:

  DeviceResult: family, brand, model

  UAResult: family, major, minor, patch

  OSResult: family, major, minor, patch, patch_minor

Code examples

  using UAParser

  #Example user-agent string
  user_agent_string = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B179 Safari/7534.48.3"

  #Get device from user-agent string
  parsedevice(user_agent_string) #> DeviceResult("iPhone", "Apple", "iPhone")

  #Get browser information from user-agent string
  parseuseragent(user_agent_string) #> UAResult("Mobile Safari","5","1",missing)

  #Get os information
  parseos(user_agent_string) #> OSResult("iOS","5","1",missing,missing)

You can index into the results of these functions like any other Julia composite type.

  #Get just browser information, no version information
  x1 = parseuseragent(user_agent_string)
  x1.family #> "Mobile Safari"

  #Get the os, no version information
  x2 = parseos(user_agent_string)
  x2.family #> "iOS"

A Note On Parser Accuracy

When this library was created, it became very obvious that it would be hard to replicate the Python parser code with 100% accuracy. The authors decided that a reasonably accurate implementation was more useful than spending the time to achieve 100% accuracy.

The tests in this library test against the accuracy of the parser. As of v0.6 of this package, here are the accuracy statistics against the files provided by the main ua-core project:

parse_device: 15144/16017 (94.6%)
parse_os: 1517/1528 (99.3%)
parse_ua: 204/205 (99.5%)

Of course, if someone would like to achieve 100% accuracy, PRs will absolutely be reviewed.

Licensing

The licensing of the UAParser Julia module is under the default MIT Expat license. The data contained in regexes.yaml is Copyright 2009 Google Inc. and available under the Apache License, Version 2.0.

uaparser.jl's People

Contributors

expandingman avatar iainnz avatar melonedo avatar randyzwitch avatar tkelman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

uaparser.jl's Issues

Tests fail

@randyzwitch

FAIL: IUC(U;iOS 5.1.1;Zh-cn;320*480;)/UCWEB7.9.0.94/41/997

I made the tests fail if there was a failure by adding some errors, this happened.

How do we get this into Coveralls?

I didn't notice when this package was moved from my personal GitHub to the centralized JuliaWeb, but the README acquired the Coveralls badge. If this is desired, how to we get this repo into Coveralls?

[PackageEvaluator.jl] Your package UAParser may have a testing issue.

This issue is being filed by a script, but if you reply, I will see it.

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their test (if available) on both the stable version of Julia (0.2) and the nightly build of the unstable version (0.3).

The results of this script are used to generate a package listing enhanced with testing results.

The status of this package, UAParser, on...

  • Julia 0.2 is 'Tests fail, but package loads.' PackageEvaluator.jl
  • Julia 0.3 is 'Tests pass.' PackageEvaluator.jl

'No tests, but package loads.' can be due to their being no tests (you should write some if you can!) but can also be due to PackageEvaluator not being able to find your tests. Consider adding a test/runtests.jl file.

'Package doesn't load.' is the worst-case scenario. Sometimes this arises because your package doesn't have BinDeps support, or needs something that can't be installed with BinDeps. If this is the case for your package, please file an issue and an exception can be made so your package will not be tested.

This automatically filed issue is a one-off message. Starting soon, issues will only be filed when the testing status of your package changes in a negative direction (gets worse). If you'd like to opt-out of these status-change messages, reply to this message.

[PkgEval] UAParser may have a testing issue on Julia 0.3 (2014-07-14)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.2) and the nightly build of the unstable version (0.3). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.3

  • On 2014-07-12 the testing status was Tests pass.
  • On 2014-07-14 the testing status changed to Package doesn't load.

Tests pass. means that PackageEvaluator found the tests for your package, executed them, and they all passed.

Package doesn't load. means that PackageEvaluator did not find tests for your package. Additionally, trying to load your package with using failed.

This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

INFO: Installing ArrayViews v0.4.6
INFO: Installing Codecs v0.1.0
INFO: Installing DataArrays v0.1.12
INFO: Installing DataFrames v0.5.6
INFO: Installing Datetime v0.1.6
INFO: Installing GZip v0.2.13
INFO: Installing Iterators v0.1.5
INFO: Installing LazySequences v0.1.0
INFO: Installing Reexport v0.0.1
INFO: Installing SortingAlgorithms v0.0.1
INFO: Installing StatsBase v0.5.3
INFO: Installing UAParser v0.2.0
INFO: Installing YAML v0.1.7
INFO: Building Datetime
INFO: Package database updated
Warning: could not import Sort.sortby into DataFrames
Warning: could not import Sort.sortby! into DataFrames
ERROR: repl_show not defined
 in include at ./boot.jl:245
 in include_from_node1 at ./loading.jl:128
 in include at ./boot.jl:245
 in include_from_node1 at ./loading.jl:128
 in reload_path at loading.jl:152
 in _require at loading.jl:67
 in require at loading.jl:54
 in include at ./boot.jl:245
 in include_from_node1 at ./loading.jl:128
 in reload_path at loading.jl:152
 in _require at loading.jl:67
 in require at loading.jl:51
 in include at ./boot.jl:245
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:285
 in _start at ./client.jl:354
while loading /home/idunning/pkgtest/.julia/v0.3/DataFrames/src/dataframe/reshape.jl, in expression starting on line 163
while loading /home/idunning/pkgtest/.julia/v0.3/DataFrames/src/DataFrames.jl, in expression starting on line 110
while loading /home/idunning/pkgtest/.julia/v0.3/UAParser/src/UAParser.jl, in expression starting on line 12
while loading /home/idunning/pkgtest/.julia/v0.3/UAParser/testusing.jl, in expression starting on line 1
INFO: Package database updated

Note this is possibly due to removal of deprecated functions in Julia 0.3-rc1: JuliaLang/julia#7609

Support pre-compiling and 0.4

Now that v0.4RC1 out, make sure everything works for 0.4, as well as support pre-compiling (although I think it would be negligible for this package).

Don't have any reason to believe there are actual issues here, just putting a placeholder for myself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.