1613786347
RAI is a non pegged, ETH backed stable asset. It is useful as more “stable” collateral for other DeFi protocols (compared to ETH or BTC) or as a stable asset with an embedded interest rate.
What is Reflexer?
Reflexer is a platform where anyone can use their crypto collateral to issue reflex indexes. Reflex indexes are stable assets that are not pegged to anything, very similar to how the US Dollar is not pegged and it is still considered stable.
Reflex indexes dampen the volatility of their underlying collateral. They are useful as more “stable” collateral for other DeFi protocols (compared to ETH or BTC) or as stable assets with embedded interest rates that supercharge other DeFi protocols.
What is RAI?
RAI is an ETH backed reflex index with a managed float regime. The RAIUSD exchange rate is determined by supply and demand while the protocol that issues RAI tries to stabilize its price by constantly de or revaluing it.
The supply and demand mechanic plays out between two parties: SAFE users (those who generate RAI with their ETH) and RAI holders (those who hold, speculate on or use RAI in other protocols and apps).
Compared to protocols that try to defend a fixed exchange rate between their native stable asset and fiat (DAI/USD, sUSD/USD etc), RAI’s monetary policy offers a couple of advantages:
How does RAI work?
The long term price trajectory of RAI is determined by the demand for ETH leverage. RAI tends to appreciate if SAFE users deleverage and/or RAI users long and it depreciates in case SAFE users leverage and/or RAI users short.
To better understand how RAI behaves, we need to analyze its monetary policy which is made out of four elements:
Let’s walk through an example of how RAI is revalued in case of ETH capital inflow (aka people are bullish on ETH):
Is RAI a stablecoin?
No. Stablecoins are pegged or oscillating around a specific value (usually pegged to fiat coins such as USD, EUR etc).
RAI, on the other hand, is not pegged to anything. The system behind RAI only cares about the market price getting as close as possible to the redemption price. The redemption price will almost always float (thus, it won’t be pegged) in order to compel system participants to bring the market price toward it.
Is RAI a rebase token?
No. The protocol doesn’t change the amount of tokens you have. Rather, it changes the target (or redemption) price that the protocol wants RAI to have on the secondary market (on exchanges).
Will I be charged fees?
The Reflexer app is free to use. However, you will need to pay transaction fees when you interact with the protocol’s smart contracts and, depending on the features you use, fees associated with RAI itself such as the Stability Fee and/or the Redemption Rate.
What is the redemption rate?
The redemption rate is similar, but not identical, to an interest rate. Its role is to devalue or revalue RAI in response to market forces.
What is the borrow rate/stability fee?
The stability fee is an interest rate charged to users who deposit collateral and mint RAI. The fee is used to incentivize external parties to maintain the protocol as well as build a surplus buffer meant to settle bad debt.
What are your plans to governance minimize RAI?
RAI will be governance minimized over three stages. We have a dedicated guide with more details about the governance minimization process. The Reflexer team will keep the community up to date with the exact timeline of each stage.
Why would I hold RAI when the system devalues the token?
This is exactly what the system wants you to ask yourself when it charges a negative redemption rate. The system is trying to incentivize RAI holders to sell and bring the market price down and close to the redemption price.
Can you summarize what users should do so they can take advantage of the PID?
Can you summarize the behaviour of the RAI redemption rate?
Why would I want to hold something that is not pegged and yet does not behave like ETH or BTC?
We often get this question from people who are used to holding assets such as DAI or USDC which seem more “stable” because they try to target a specific peg.
While it is true that the mechanism behind RAI may cause more uncertainty vs pegged coins because of the floating redemption price, it also comes with its own perks:
It is also worth considering that only some fiat currencies are pegged, while others float and they are still considered “stable”. The most well known example of a stable currency with no peg is the US Dollar. Check out this classification of exchange rate arrangements which shows the full spectrum of stability.
Why would I want to mint RAI?
We have both short and long term plans meant to attract borrowers and improve the experience of interacting with the protocol:
What are RAI’s use-cases?
The following is a non-exhaustive list of use-cases we envision for RAI:
What are the risks of using Reflexer and RAI?
There are several risks associated with using Reflexer and RAI, ranging from smart contract bugs to suboptimal parameters set in the protocol. You can check our dedicated risks page for more details as well as read more about each protocol module.
What are the assumptions behind RAI’s mechanism?
RAI’s success depends on three main factors:
It’s worth noting that the narrative attracts liquidity and arbitrageurs which in turn can further strengthen the narrative.
A stepping stone in on-chain control theory
After months of research and building, we’re excited to unveil our first, full Ether backed asset called Proto RAI!
What is Proto RAI?
Proto RAI (PRAI) is an unaudited mainnet demo of our upcoming reflex index called RAI. PRAI is managed and repriced by a primitive version of our on-chain, autonomous PID controller. Check our whitepaper for a description of the controller and for the system as a whole.
The purpose of this demo is to test and improve our tooling and smart contracts, bootstrap an initial group of keepers that liquidate undercollateralized positions as well as gather live data which can help us update our market model and simulations. This is why in the first couple of weeks we will focus exclusively on developers. After we finish our initial audits we will invite more people to join.
If you would like to monitor the system, you can use this simple dashboard.
How Do I Create PRAI?
In order to create PRAI, you need to deposit Wrapped ETH into a smart contract and open a new position which we call a “Safe”.
At this stage we do not have a webapp to facilitate the creation of PRAI although we encourage developers to use our Typescript and Python libraries as well as our CLI in order to interact with the system. This video guide and our documentation walk you through using the Typescript library with proxy contracts in order to generate PRAI backed by (W)ETH.
We advise everyone to exercise caution and avoid using large amounts of Ether when they test the system. Do not risk more than you can afford to lose.
What Can I Do with PRAI?
Currently you can trade PRAI for ETH using this Uniswap V2 pool. Please be aware that the pool does not have a lot of liquidity.
There are several system parameters that everyone should be aware of:
Bumpy Start
After we deployed the system, we discovered that we did not properly set authorized addresses inside the ERC20 PRAI contract. Because of this, we were not able to add new authed accounts or remove old ones.
We decided to disable the original CoinJoin contract which allows users to transfer PRAI between the core system and the ERC20 contract. Users (mostly bots that traded in the old Uniswap pool) who hold old PRAI tokens can now call the old CoinJoin in order to join() tokens inside the system. They can then use the latest CoinJoin and Coin contracts in order to get new PRAI tokens and trade using the new Uniswap PRAI/ETH pool.
We also had to disable the old treasury and abandon the initial Uniswap v2 PRAI oracle in favor of new versions that are integrated with the latest Coin/CoinJoin.
Crypto native stability backed by ETH and available for all
After almost a year of testing, simulations and building, we’re thrilled to announce the launch of RAI! RAI is an ETH backed, non pegged stable asset whose monetary policy is managed by an on-chain, autonomous controller. You can start to mint RAI today using our dashboard. RAI was deployed at this address and the Uniswap v2 RAI/ETH market is here.
Prior to this launch, Proto RAI, our mainnet demo, ran smoothly for almost 3 months and was shut down on 25th of January. We’ve received great support from our community who put more than $612K worth of ETH in the demo and minted almost 52K PRAI.
Proto RAI also showed for the first time how a stable asset can lack a peg and instead have its redemption price float in response to market forces. PRAI’s redemption price started at $2.015 and then floated between $1.937 and $2.06. This happened with no professional market makers, almost no liquidity and a lack of arbitrageurs which would have made PRAI significantly more stable. Moreover, during the PRAI demo, ETH went from about $400 to $1400, a 350% increase, while PRAI’s redemption price fluctuated less than 4%.
To summarize PRAI’s behaviour, when its market price was consistently above the redemption price, redemption would start to go down. Similarly, if the market price was consistently below the redemption price, redemption would start to go up. You can read more about how the system behind P/RAI works in our FAQ.
Liquidity Incentives
In the next couple of weeks we will announce our liquidity mining program for the RAI/ETH Uniswap v2 pool. At that point, we will also reveal the Reflexer ungovernance token, FLX.
In the meantime, we’re not saying that there will be retroactive mining rewards for the initial cohort of RAI/ETH LPs, but we’re also not saying there won’t be.
Before the liquidity mining announcement, you can test our Kovan liquidity mining dashboard.
Kovan Liquidity Mining Interface
Phased Controller Launch
For the time being and until RAI has enough liquidity on Uniswap v2, the controller will be weaker than usual. We will soon update the community with the minimum amount of liquidity that must be on exchanges so that the controller is not easy to manipulate. Until then, we encourage you to check our PID risks documentation before using RAI.
RAI Parameters
RAI was launched with a starting redemption price of $3.14. From this point on, RAI will continue to float while it is managed by the protocol’s on-chain controller.
In the foreseeable future, we plan to set an annual RAI borrow rate between 2–4%. We believe that a rate in this range will be able to provide the system with enough capital so it pays keepers to maintain oracles and the controller as well as fill the surplus buffer.
You can read more about the rest of the parameters in our docs.
Security
Proto RAI has been beta tested for almost 3 months on mainnet Ethereum. The core contracts were audited by OpenZeppelin and the helper contracts (oracles, PID etc) were audited by Quantstamp and Solidified. However, audits do not guarantee that smart contracts are bug free so we advise everyone to be cautious when using the protocol.
We have an open bug bounty program where you can earn up to $30K. We also wrote here in more detail about major risks associated with using RAI.
Resources
Whitepaper: https://github.com/reflexer-labs/whitepapers
Documentation: https://docs.reflexer.finance/
Video Guide on How to Create PRAI: https://www.youtube.com/watch?v=6rD7MjUaJUA
Stats Dashboard: https://stats.reflexer.finance/
Mainnet Subgraph: https://thegraph.com/explorer/subgraph/reflexer-labs/prai-mainnet
Uniswap PRAI/ETH Pool: https://info.uniswap.org/pair/0xEBdE9F61e34B7aC5aAE5A4170E964eA85988008C
Looking for more information…
☞ Website ☞ Explorer ☞ Explorer 2 ☞ Whitepaper ☞ Source Code ☞ Social Channel ☞ Social Channel 2 ☞ Message Board ☞ Coinmarketcap
Would you like to earn RAI right now! ☞ CLICK HERE
Top exchanges for token-coin trading. Follow instructions and make unlimited money
☞ Binance ☞ Bittrex ☞ Poloniex ☞ Bitfinex ☞ Huobi
Thank for visiting and reading this article! I’m highly appreciate your actions! Please share if you liked it!
#blockchain #bitcoin #rai reflex index #rai
1613786347
RAI is a non pegged, ETH backed stable asset. It is useful as more “stable” collateral for other DeFi protocols (compared to ETH or BTC) or as a stable asset with an embedded interest rate.
What is Reflexer?
Reflexer is a platform where anyone can use their crypto collateral to issue reflex indexes. Reflex indexes are stable assets that are not pegged to anything, very similar to how the US Dollar is not pegged and it is still considered stable.
Reflex indexes dampen the volatility of their underlying collateral. They are useful as more “stable” collateral for other DeFi protocols (compared to ETH or BTC) or as stable assets with embedded interest rates that supercharge other DeFi protocols.
What is RAI?
RAI is an ETH backed reflex index with a managed float regime. The RAIUSD exchange rate is determined by supply and demand while the protocol that issues RAI tries to stabilize its price by constantly de or revaluing it.
The supply and demand mechanic plays out between two parties: SAFE users (those who generate RAI with their ETH) and RAI holders (those who hold, speculate on or use RAI in other protocols and apps).
Compared to protocols that try to defend a fixed exchange rate between their native stable asset and fiat (DAI/USD, sUSD/USD etc), RAI’s monetary policy offers a couple of advantages:
How does RAI work?
The long term price trajectory of RAI is determined by the demand for ETH leverage. RAI tends to appreciate if SAFE users deleverage and/or RAI users long and it depreciates in case SAFE users leverage and/or RAI users short.
To better understand how RAI behaves, we need to analyze its monetary policy which is made out of four elements:
Let’s walk through an example of how RAI is revalued in case of ETH capital inflow (aka people are bullish on ETH):
Is RAI a stablecoin?
No. Stablecoins are pegged or oscillating around a specific value (usually pegged to fiat coins such as USD, EUR etc).
RAI, on the other hand, is not pegged to anything. The system behind RAI only cares about the market price getting as close as possible to the redemption price. The redemption price will almost always float (thus, it won’t be pegged) in order to compel system participants to bring the market price toward it.
Is RAI a rebase token?
No. The protocol doesn’t change the amount of tokens you have. Rather, it changes the target (or redemption) price that the protocol wants RAI to have on the secondary market (on exchanges).
Will I be charged fees?
The Reflexer app is free to use. However, you will need to pay transaction fees when you interact with the protocol’s smart contracts and, depending on the features you use, fees associated with RAI itself such as the Stability Fee and/or the Redemption Rate.
What is the redemption rate?
The redemption rate is similar, but not identical, to an interest rate. Its role is to devalue or revalue RAI in response to market forces.
What is the borrow rate/stability fee?
The stability fee is an interest rate charged to users who deposit collateral and mint RAI. The fee is used to incentivize external parties to maintain the protocol as well as build a surplus buffer meant to settle bad debt.
What are your plans to governance minimize RAI?
RAI will be governance minimized over three stages. We have a dedicated guide with more details about the governance minimization process. The Reflexer team will keep the community up to date with the exact timeline of each stage.
Why would I hold RAI when the system devalues the token?
This is exactly what the system wants you to ask yourself when it charges a negative redemption rate. The system is trying to incentivize RAI holders to sell and bring the market price down and close to the redemption price.
Can you summarize what users should do so they can take advantage of the PID?
Can you summarize the behaviour of the RAI redemption rate?
Why would I want to hold something that is not pegged and yet does not behave like ETH or BTC?
We often get this question from people who are used to holding assets such as DAI or USDC which seem more “stable” because they try to target a specific peg.
While it is true that the mechanism behind RAI may cause more uncertainty vs pegged coins because of the floating redemption price, it also comes with its own perks:
It is also worth considering that only some fiat currencies are pegged, while others float and they are still considered “stable”. The most well known example of a stable currency with no peg is the US Dollar. Check out this classification of exchange rate arrangements which shows the full spectrum of stability.
Why would I want to mint RAI?
We have both short and long term plans meant to attract borrowers and improve the experience of interacting with the protocol:
What are RAI’s use-cases?
The following is a non-exhaustive list of use-cases we envision for RAI:
What are the risks of using Reflexer and RAI?
There are several risks associated with using Reflexer and RAI, ranging from smart contract bugs to suboptimal parameters set in the protocol. You can check our dedicated risks page for more details as well as read more about each protocol module.
What are the assumptions behind RAI’s mechanism?
RAI’s success depends on three main factors:
It’s worth noting that the narrative attracts liquidity and arbitrageurs which in turn can further strengthen the narrative.
A stepping stone in on-chain control theory
After months of research and building, we’re excited to unveil our first, full Ether backed asset called Proto RAI!
What is Proto RAI?
Proto RAI (PRAI) is an unaudited mainnet demo of our upcoming reflex index called RAI. PRAI is managed and repriced by a primitive version of our on-chain, autonomous PID controller. Check our whitepaper for a description of the controller and for the system as a whole.
The purpose of this demo is to test and improve our tooling and smart contracts, bootstrap an initial group of keepers that liquidate undercollateralized positions as well as gather live data which can help us update our market model and simulations. This is why in the first couple of weeks we will focus exclusively on developers. After we finish our initial audits we will invite more people to join.
If you would like to monitor the system, you can use this simple dashboard.
How Do I Create PRAI?
In order to create PRAI, you need to deposit Wrapped ETH into a smart contract and open a new position which we call a “Safe”.
At this stage we do not have a webapp to facilitate the creation of PRAI although we encourage developers to use our Typescript and Python libraries as well as our CLI in order to interact with the system. This video guide and our documentation walk you through using the Typescript library with proxy contracts in order to generate PRAI backed by (W)ETH.
We advise everyone to exercise caution and avoid using large amounts of Ether when they test the system. Do not risk more than you can afford to lose.
What Can I Do with PRAI?
Currently you can trade PRAI for ETH using this Uniswap V2 pool. Please be aware that the pool does not have a lot of liquidity.
There are several system parameters that everyone should be aware of:
Bumpy Start
After we deployed the system, we discovered that we did not properly set authorized addresses inside the ERC20 PRAI contract. Because of this, we were not able to add new authed accounts or remove old ones.
We decided to disable the original CoinJoin contract which allows users to transfer PRAI between the core system and the ERC20 contract. Users (mostly bots that traded in the old Uniswap pool) who hold old PRAI tokens can now call the old CoinJoin in order to join() tokens inside the system. They can then use the latest CoinJoin and Coin contracts in order to get new PRAI tokens and trade using the new Uniswap PRAI/ETH pool.
We also had to disable the old treasury and abandon the initial Uniswap v2 PRAI oracle in favor of new versions that are integrated with the latest Coin/CoinJoin.
Crypto native stability backed by ETH and available for all
After almost a year of testing, simulations and building, we’re thrilled to announce the launch of RAI! RAI is an ETH backed, non pegged stable asset whose monetary policy is managed by an on-chain, autonomous controller. You can start to mint RAI today using our dashboard. RAI was deployed at this address and the Uniswap v2 RAI/ETH market is here.
Prior to this launch, Proto RAI, our mainnet demo, ran smoothly for almost 3 months and was shut down on 25th of January. We’ve received great support from our community who put more than $612K worth of ETH in the demo and minted almost 52K PRAI.
Proto RAI also showed for the first time how a stable asset can lack a peg and instead have its redemption price float in response to market forces. PRAI’s redemption price started at $2.015 and then floated between $1.937 and $2.06. This happened with no professional market makers, almost no liquidity and a lack of arbitrageurs which would have made PRAI significantly more stable. Moreover, during the PRAI demo, ETH went from about $400 to $1400, a 350% increase, while PRAI’s redemption price fluctuated less than 4%.
To summarize PRAI’s behaviour, when its market price was consistently above the redemption price, redemption would start to go down. Similarly, if the market price was consistently below the redemption price, redemption would start to go up. You can read more about how the system behind P/RAI works in our FAQ.
Liquidity Incentives
In the next couple of weeks we will announce our liquidity mining program for the RAI/ETH Uniswap v2 pool. At that point, we will also reveal the Reflexer ungovernance token, FLX.
In the meantime, we’re not saying that there will be retroactive mining rewards for the initial cohort of RAI/ETH LPs, but we’re also not saying there won’t be.
Before the liquidity mining announcement, you can test our Kovan liquidity mining dashboard.
Kovan Liquidity Mining Interface
Phased Controller Launch
For the time being and until RAI has enough liquidity on Uniswap v2, the controller will be weaker than usual. We will soon update the community with the minimum amount of liquidity that must be on exchanges so that the controller is not easy to manipulate. Until then, we encourage you to check our PID risks documentation before using RAI.
RAI Parameters
RAI was launched with a starting redemption price of $3.14. From this point on, RAI will continue to float while it is managed by the protocol’s on-chain controller.
In the foreseeable future, we plan to set an annual RAI borrow rate between 2–4%. We believe that a rate in this range will be able to provide the system with enough capital so it pays keepers to maintain oracles and the controller as well as fill the surplus buffer.
You can read more about the rest of the parameters in our docs.
Security
Proto RAI has been beta tested for almost 3 months on mainnet Ethereum. The core contracts were audited by OpenZeppelin and the helper contracts (oracles, PID etc) were audited by Quantstamp and Solidified. However, audits do not guarantee that smart contracts are bug free so we advise everyone to be cautious when using the protocol.
We have an open bug bounty program where you can earn up to $30K. We also wrote here in more detail about major risks associated with using RAI.
Resources
Whitepaper: https://github.com/reflexer-labs/whitepapers
Documentation: https://docs.reflexer.finance/
Video Guide on How to Create PRAI: https://www.youtube.com/watch?v=6rD7MjUaJUA
Stats Dashboard: https://stats.reflexer.finance/
Mainnet Subgraph: https://thegraph.com/explorer/subgraph/reflexer-labs/prai-mainnet
Uniswap PRAI/ETH Pool: https://info.uniswap.org/pair/0xEBdE9F61e34B7aC5aAE5A4170E964eA85988008C
Looking for more information…
☞ Website ☞ Explorer ☞ Explorer 2 ☞ Whitepaper ☞ Source Code ☞ Social Channel ☞ Social Channel 2 ☞ Message Board ☞ Coinmarketcap
Would you like to earn RAI right now! ☞ CLICK HERE
Top exchanges for token-coin trading. Follow instructions and make unlimited money
☞ Binance ☞ Bittrex ☞ Poloniex ☞ Bitfinex ☞ Huobi
Thank for visiting and reading this article! I’m highly appreciate your actions! Please share if you liked it!
#blockchain #bitcoin #rai reflex index #rai
1658068560
WordsCounted
We are all in the gutter, but some of us are looking at the stars.
-- Oscar Wilde
WordsCounted is a Ruby NLP (natural language processor). WordsCounted lets you implement powerful tokensation strategies with a very flexible tokeniser class.
["Bayrūt"]
and not ["Bayr", "ū", "t"]
, for example.Add this line to your application's Gemfile:
gem 'words_counted'
And then execute:
$ bundle
Or install it yourself as:
$ gem install words_counted
Pass in a string or a file path, and an optional filter and/or regexp.
counter = WordsCounted.count(
"We are all in the gutter, but some of us are looking at the stars."
)
# Using a file
counter = WordsCounted.from_file("path/or/url/to/my/file.txt")
.count
and .from_file
are convenience methods that take an input, tokenise it, and return an instance of WordsCounted::Counter
initialized with the tokens. The WordsCounted::Tokeniser
and WordsCounted::Counter
classes can be used alone, however.
WordsCounted.count(input, options = {})
Tokenises input and initializes a WordsCounted::Counter
object with the resulting tokens.
counter = WordsCounted.count("Hello Beirut!")
Accepts two options: exclude
and regexp
. See Excluding tokens from the analyser and Passing in a custom regexp respectively.
WordsCounted.from_file(path, options = {})
Reads and tokenises a file, and initializes a WordsCounted::Counter
object with the resulting tokens.
counter = WordsCounted.from_file("hello_beirut.txt")
Accepts the same options as .count
.
The tokeniser allows you to tokenise text in a variety of ways. You can pass in your own rules for tokenisation, and apply a powerful filter with any combination of rules as long as they can boil down into a lambda.
Out of the box the tokeniser includes only alpha chars. Hyphenated tokens and tokens with apostrophes are considered a single token.
#tokenise([pattern: TOKEN_REGEXP, exclude: nil])
tokeniser = WordsCounted::Tokeniser.new("Hello Beirut!").tokenise
# With `exclude`
tokeniser = WordsCounted::Tokeniser.new("Hello Beirut!").tokenise(exclude: "hello")
# With `pattern`
tokeniser = WordsCounted::Tokeniser.new("I <3 Beirut!").tokenise(pattern: /[a-z]/i)
See Excluding tokens from the analyser and Passing in a custom regexp for more information.
The WordsCounted::Counter
class allows you to collect various statistics from an array of tokens.
#token_count
Returns the token count of a given string.
counter.token_count #=> 15
#token_frequency
Returns a sorted (unstable) two-dimensional array where each element is a token and its frequency. The array is sorted by frequency in descending order.
counter.token_frequency
[
["the", 2],
["are", 2],
["we", 1],
# ...
["all", 1]
]
#most_frequent_tokens
Returns a hash where each key-value pair is a token and its frequency.
counter.most_frequent_tokens
{ "are" => 2, "the" => 2 }
#token_lengths
Returns a sorted (unstable) two-dimentional array where each element contains a token and its length. The array is sorted by length in descending order.
counter.token_lengths
[
["looking", 7],
["gutter", 6],
["stars", 5],
# ...
["in", 2]
]
#longest_tokens
Returns a hash where each key-value pair is a token and its length.
counter.longest_tokens
{ "looking" => 7 }
#token_density([ precision: 2 ])
Returns a sorted (unstable) two-dimentional array where each element contains a token and its density as a float, rounded to a precision of two. The array is sorted by density in descending order. It accepts a precision
argument, which must be a float.
counter.token_density
[
["are", 0.13],
["the", 0.13],
["but", 0.07 ],
# ...
["we", 0.07 ]
]
#char_count
Returns the char count of tokens.
counter.char_count #=> 76
#average_chars_per_token([ precision: 2 ])
Returns the average char count per token rounded to two decimal places. Accepts a precision argument which defaults to two. Precision must be a float.
counter.average_chars_per_token #=> 4
#uniq_token_count
Returns the number of unique tokens.
counter.uniq_token_count #=> 13
You can exclude anything you want from the input by passing the exclude
option. The exclude option accepts a variety of filters and is extremely flexible.
:odd?
.tokeniser =
WordsCounted::Tokeniser.new(
"Magnificent! That was magnificent, Trevor."
)
# Using a string
tokeniser.tokenise(exclude: "was magnificent")
# => ["that", "trevor"]
# Using a regular expression
tokeniser.tokenise(exclude: /trevor/)
# => ["magnificent", "that", "was", "magnificent"]
# Using a lambda
tokeniser.tokenise(exclude: ->(t) { t.length < 4 })
# => ["magnificent", "that", "magnificent", "trevor"]
# Using symbol
tokeniser = WordsCounted::Tokeniser.new("Hello! محمد")
tokeniser.tokenise(exclude: :ascii_only?)
# => ["محمد"]
# Using an array
tokeniser = WordsCounted::Tokeniser.new(
"Hello! اسماءنا هي محمد، كارولينا، سامي، وداني"
)
tokeniser.tokenise(
exclude: [:ascii_only?, /محمد/, ->(t) { t.length > 6}, "و"]
)
# => ["هي", "سامي", "وداني"]
The default regexp accounts for letters, hyphenated tokens, and apostrophes. This means twenty-one is treated as one token. So is Mohamad's.
/[\p{Alpha}\-']+/
You can pass your own criteria as a Ruby regular expression to split your string as desired.
For example, if you wanted to include numbers, you can override the regular expression:
counter = WordsCounted.count("Numbers 1, 2, and 3", pattern: /[\p{Alnum}\-']+/)
counter.tokens
#=> ["numbers", "1", "2", "and", "3"]
Use the from_file
method to open files. from_file
accepts the same options as .count
. The file path can be a URL.
counter = WordsCounted.from_file("url/or/path/to/file.text")
A hyphen used in leu of an em or en dash will form part of the token. This affects the tokeniser algorithm.
counter = WordsCounted.count("How do you do?-you are well, I see.")
counter.token_frequency
[
["do", 2],
["how", 1],
["you", 1],
["-you", 1], # WTF, mate!
["are", 1],
# ...
]
In this example -you
and you
are separate tokens. Also, the tokeniser does not include numbers by default. Remember that you can pass your own regular expression if the default behaviour does not fit your needs.
The program will normalise (downcase) all incoming strings for consistency and filters.
def self.from_url
# open url and send string here after removing html
end
Are you using WordsCounted to do something interesting? Please tell me about it.
Visit this website for one example of what you can do with WordsCounted.
Contributors
See contributors.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Author: Abitdodgy
Source Code: https://github.com/abitdodgy/words_counted
License: MIT license
1659601560
We are all in the gutter, but some of us are looking at the stars.
-- Oscar Wilde
WordsCounted is a Ruby NLP (natural language processor). WordsCounted lets you implement powerful tokensation strategies with a very flexible tokeniser class.
Are you using WordsCounted to do something interesting? Please tell me about it.
Visit this website for one example of what you can do with WordsCounted.
["Bayrūt"]
and not ["Bayr", "ū", "t"]
, for example.Add this line to your application's Gemfile:
gem 'words_counted'
And then execute:
$ bundle
Or install it yourself as:
$ gem install words_counted
Pass in a string or a file path, and an optional filter and/or regexp.
counter = WordsCounted.count(
"We are all in the gutter, but some of us are looking at the stars."
)
# Using a file
counter = WordsCounted.from_file("path/or/url/to/my/file.txt")
.count
and .from_file
are convenience methods that take an input, tokenise it, and return an instance of WordsCounted::Counter
initialized with the tokens. The WordsCounted::Tokeniser
and WordsCounted::Counter
classes can be used alone, however.
WordsCounted.count(input, options = {})
Tokenises input and initializes a WordsCounted::Counter
object with the resulting tokens.
counter = WordsCounted.count("Hello Beirut!")
Accepts two options: exclude
and regexp
. See Excluding tokens from the analyser and Passing in a custom regexp respectively.
WordsCounted.from_file(path, options = {})
Reads and tokenises a file, and initializes a WordsCounted::Counter
object with the resulting tokens.
counter = WordsCounted.from_file("hello_beirut.txt")
Accepts the same options as .count
.
The tokeniser allows you to tokenise text in a variety of ways. You can pass in your own rules for tokenisation, and apply a powerful filter with any combination of rules as long as they can boil down into a lambda.
Out of the box the tokeniser includes only alpha chars. Hyphenated tokens and tokens with apostrophes are considered a single token.
#tokenise([pattern: TOKEN_REGEXP, exclude: nil])
tokeniser = WordsCounted::Tokeniser.new("Hello Beirut!").tokenise
# With `exclude`
tokeniser = WordsCounted::Tokeniser.new("Hello Beirut!").tokenise(exclude: "hello")
# With `pattern`
tokeniser = WordsCounted::Tokeniser.new("I <3 Beirut!").tokenise(pattern: /[a-z]/i)
See Excluding tokens from the analyser and Passing in a custom regexp for more information.
The WordsCounted::Counter
class allows you to collect various statistics from an array of tokens.
#token_count
Returns the token count of a given string.
counter.token_count #=> 15
#token_frequency
Returns a sorted (unstable) two-dimensional array where each element is a token and its frequency. The array is sorted by frequency in descending order.
counter.token_frequency
[
["the", 2],
["are", 2],
["we", 1],
# ...
["all", 1]
]
#most_frequent_tokens
Returns a hash where each key-value pair is a token and its frequency.
counter.most_frequent_tokens
{ "are" => 2, "the" => 2 }
#token_lengths
Returns a sorted (unstable) two-dimentional array where each element contains a token and its length. The array is sorted by length in descending order.
counter.token_lengths
[
["looking", 7],
["gutter", 6],
["stars", 5],
# ...
["in", 2]
]
#longest_tokens
Returns a hash where each key-value pair is a token and its length.
counter.longest_tokens
{ "looking" => 7 }
#token_density([ precision: 2 ])
Returns a sorted (unstable) two-dimentional array where each element contains a token and its density as a float, rounded to a precision of two. The array is sorted by density in descending order. It accepts a precision
argument, which must be a float.
counter.token_density
[
["are", 0.13],
["the", 0.13],
["but", 0.07 ],
# ...
["we", 0.07 ]
]
#char_count
Returns the char count of tokens.
counter.char_count #=> 76
#average_chars_per_token([ precision: 2 ])
Returns the average char count per token rounded to two decimal places. Accepts a precision argument which defaults to two. Precision must be a float.
counter.average_chars_per_token #=> 4
#uniq_token_count
Returns the number of unique tokens.
counter.uniq_token_count #=> 13
You can exclude anything you want from the input by passing the exclude
option. The exclude option accepts a variety of filters and is extremely flexible.
:odd?
.tokeniser =
WordsCounted::Tokeniser.new(
"Magnificent! That was magnificent, Trevor."
)
# Using a string
tokeniser.tokenise(exclude: "was magnificent")
# => ["that", "trevor"]
# Using a regular expression
tokeniser.tokenise(exclude: /trevor/)
# => ["magnificent", "that", "was", "magnificent"]
# Using a lambda
tokeniser.tokenise(exclude: ->(t) { t.length < 4 })
# => ["magnificent", "that", "magnificent", "trevor"]
# Using symbol
tokeniser = WordsCounted::Tokeniser.new("Hello! محمد")
tokeniser.tokenise(exclude: :ascii_only?)
# => ["محمد"]
# Using an array
tokeniser = WordsCounted::Tokeniser.new(
"Hello! اسماءنا هي محمد، كارولينا، سامي، وداني"
)
tokeniser.tokenise(
exclude: [:ascii_only?, /محمد/, ->(t) { t.length > 6}, "و"]
)
# => ["هي", "سامي", "وداني"]
The default regexp accounts for letters, hyphenated tokens, and apostrophes. This means twenty-one is treated as one token. So is Mohamad's.
/[\p{Alpha}\-']+/
You can pass your own criteria as a Ruby regular expression to split your string as desired.
For example, if you wanted to include numbers, you can override the regular expression:
counter = WordsCounted.count("Numbers 1, 2, and 3", pattern: /[\p{Alnum}\-']+/)
counter.tokens
#=> ["numbers", "1", "2", "and", "3"]
Use the from_file
method to open files. from_file
accepts the same options as .count
. The file path can be a URL.
counter = WordsCounted.from_file("url/or/path/to/file.text")
A hyphen used in leu of an em or en dash will form part of the token. This affects the tokeniser algorithm.
counter = WordsCounted.count("How do you do?-you are well, I see.")
counter.token_frequency
[
["do", 2],
["how", 1],
["you", 1],
["-you", 1], # WTF, mate!
["are", 1],
# ...
]
In this example -you
and you
are separate tokens. Also, the tokeniser does not include numbers by default. Remember that you can pass your own regular expression if the default behaviour does not fit your needs.
The program will normalise (downcase) all incoming strings for consistency and filters.
def self.from_url
# open url and send string here after removing html
end
See contributors.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Author: abitdodgy
Source code: https://github.com/abitdodgy/words_counted
License: MIT license
#ruby #ruby-on-rails
1622197808
SafeMoon is a decentralized finance (DeFi) token. This token consists of RFI tokenomics and auto-liquidity generating protocol. A DeFi token like SafeMoon has reached the mainstream standards under the Binance Smart Chain. Its success and popularity have been immense, thus, making the majority of the business firms adopt this style of cryptocurrency as an alternative.
A DeFi token like SafeMoon is almost similar to the other crypto-token, but the only difference being that it charges a 10% transaction fee from the users who sell their tokens, in which 5% of the fee is distributed to the remaining SafeMoon owners. This feature rewards the owners for holding onto their tokens.
Read More @ https://bit.ly/3oFbJoJ
#create a defi token like safemoon #defi token like safemoon #safemoon token #safemoon token clone #defi token
1621844791
The SafeMoon Token Clone Development is the new trendsetter in the digital world that brought significant changes to benefit the growth of investors’ business in a short period. The SafeMoon token clone is the most widely discussed topic among global users for its value soaring high in the marketplace. The SafeMoon token development is a combination of RFI tokenomics and the auto-liquidity generating process. The SafeMoon token is a replica of decentralized finance (DeFi) tokens that are highly scalable and implemented with tamper-proof security.
The SafeMoon tokens execute efficient functionalities like RFI Static Rewards, Automated Liquidity Provisions, and Automatic Token Burns. The SafeMoon token is considered the most advanced stable coin in the crypto market. It gained global audience attention for managing the stability of asset value without any fluctuations in the marketplace. The SafeMoon token clone is completely decentralized that eliminates the need for intermediaries and benefits the users with less transaction fee and wait time to overtake the traditional banking process.
The SafeMoon Token Clone Development is a promising future for upcoming investors and startups to increase their business revenue in less time. The SafeMoon token clone has great demand in the real world among millions of users for its value in the market. Investors can contact leading Infinite Block Tech to gain proper assistance in developing a world-class SafeMoon token clone that increases the business growth in less time.
#safemoon token #safemoon token clone #safemoon token clone development #defi token