Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
AnyStyle is a fast and smart parser of bibliographic references. Originally inspired by parsCit and FreeCite, AnyStyle uses machine learning algorithms and aims to make it easy to train models with data that's relevant to you.
$ [sudo] gem install anystyle-cli
$ anystyle --help
$ anystyle help find
$ anystyle help parse
See anystyle-cli for more details.
Install the anystyle
gem.
$ [sudo] gem install anystyle
Now you can use the static Parser and Finder instances
by calling the AnyStyle.parse
or AnyStyle.find
methods.
For example:
require 'anystyle'
pp AnyStyle.parse 'Derrida, J. (1967). L’écriture et la différence (1 éd.). Paris: Éditions du Seuil.'
#-> [{
# :author=>[{:family=>"Derrida", :given=>"J."}],
# :date=>["1967"],
# :title=>["L’écriture et la différence"],
# :edition=>["1"],
# :location=>["Paris"],
# :publisher=>["Éditions du Seuil"],
# :language=>"fr",
# :scripts=>["Common", "Latin"],
# :type=>"book"
#}]
You can also create your own
AnyStyle::Parser
or AnyStyle::Finder
with custom options.
AnyStyle is available at anystyle.io.
The web application is open source and you're welcome to host your own instance!
You can train custom Finder and Parser models. To do this, you need to prepare your own data sets for training. You can create your own data from scratch or build on AnyStyle's default sets. The default parser model uses the core data set. And though the finder model sources aren't available in their entirety, due to copyright restrictions, you can find several tagged documents here.
When you have compiled a data set for training, you will be ready to create your own model:
$ anystyle train training-data.xml custom.mod
This will save your new model as custom.mod
.
To use your model instead of AnyStyle's default,
use the -P
or --parser-model
flag and, respectively,
-F
or --finder-model
to use a custom finder model.
For instance, the command below
will parse a file bib.txt
with the custom model
and print the result to STDOUT in JSON format:
$ anystyle -P custom.mod -f json parse bib.txt -
When training your own models, it's good practice to check their quality using a second data set. For example, to check your custom model using AnyStyle's manually curated gold data set:
$ anystyle -P x.mod check ./res/parser/gold.xml
Checking gold.xml................. 1 seq 0.06% 3 tok 0.01% 3s
This command prints sequence and token error rates. Here, sequence errors are the number of references tagged differently by the parser as compared to the curated input; the number of token errors is the total number of words in these references. In the example above, one reference was wrong (out of 1,700 at the time), because a total of three words had a different tag.
When working with training data,
it's a good idea to use the Wapiti::Dataset
API in Ruby:
it supports standard set operators
and makes it easy to combine or compare data sets.
The core data set contains the manually marked-up references which comprise AnyStyle's default parser model. If your references include non-English documents, the distribution of natural languages in this corpus is relevant.
Language | n |
---|---|
ENGLISH | 965 |
FRENCH | 54 |
GERMAN | 26 |
ITALIAN | 11 |
Others | 9 |
Not reliably determined | 449 |
(but mainly English) |
(Measured using cld and AnyStyle version 1.3.13)
There is a strong prevalence of English-language documents with the conventions used in English-language bibliographies, with some representation of other European languages. The languages used reflect those used in scientific publishing as well as the maintainers' competencies. If you are working with documents in languages other than English, you might consider training the model with some examples in the relevant languages.
AnyStyle works with references written in any Latin script, including most European languages, languages such as Indonesian and Malaysian, as well as romanized Arabic, Chinese and Japanese. It also supports non-Latin alphabets such as Cyrillic, although no examples of these appear in the default training sets. Languages written in syllabaries or complex symbols which don't use white space to separate tokens aren't compatible with AnyStyle's approach: this includes Chinese, Japanese, Arabic, and Indian languages.
During the statistical analysis of reference strings,
AnyStyle relies on a large feature dictionary;
by default, AnyStyle creates a persistent Ruby hash
in the folder of the anystyle-data
Gem.
This uses up about 2MB of disk space
and keeps the entire dictionary in memory.
If you prefer a smaller memory footprint,
you can use AnyStyle's GDBM dictionary.
GDBM bindings are part of the Ruby standard library
and supported on all platforms,
though you may need to install GDBM before installing Ruby.
If you don't want to use the persistent Ruby hash nor GBDM, you can store your dictionary in memory or use a Redis. The best way to change the default dictionary adapter is by adjusting AnyStyle's default configuration (when using the static parser instances you must set the default before using the parser):
AnyStyle::Dictionary.defaults[:adapter] = :ruby
#-> Use a persistent Ruby hash;
#-> slower start-up than GDBM but no extra dependency
AnyStyle::Dictionary.defaults[:adapter] = :hash
#-> Use in-memory dictionary; slow start-up but uses no space on disk
require 'anystyle/dictionary/gdbm'
AnyStyle::Dictionary.defaults[:adapter] = :gdbm
To use Redis, install the redis
and redis/namespace
(optional) Gems
and configure AnyStyle to use the Redis adapter:
AnyStyle::Dictionary.defaults[:adapter] = :redis
# Adjust the Redis-specifi configuration
require 'anystyle/dictionary/redis'
AnyStyle::Dictionary::Redis.defaults[:host] = 'localhost'
AnyStyle::Dictionary::Redis.defaults[:port] = 6379
The AnyStyle source code is hosted on GitHub. You can check out a copy of the latest code using Git:
$ git clone https://github.com/inukshuk/anystyle.git
If you've found a bug or have a question, please report the issue or, for extra credit, clone the AnyStyle repository, write a failing example, fix the bug and submit a pull request.
AnyStyle is a volunteer effort and you're encourage to join! Over the years the main contributors have been:
Copyright 2011-2023 Sylvester Keil. All rights reserved.
AnyStyle is distributed under a BSD-style license. See LICENSE for details.
FAQs
Unknown package
We found that anystyle demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.