Skip to content

Commit

Permalink
Support currency compound unit (#412)
Browse files Browse the repository at this point in the history
* Support compound unit's patterns
* Basic support for currency compound units
- refactor the extractor and parser of NumberWithUnit
- add BaseCurrencyParser
* Update patterns and revise tests
- Support optional IsoCurrency in Resolution
- Fix js tests
* Comments fixes
* Fix minor issue in mergedExtractor
* Comments fixes
- update English pattern to support more written chinese currencies.
- add code comments
* Revise code
- remove SYS_UNIT_COMPOUND
* Merge master and resolve conflicts
  • Loading branch information
sanxing-chen authored and tellarin committed Apr 12, 2018
1 parent 3e51bb9 commit 4d8389e
Show file tree
Hide file tree
Showing 54 changed files with 2,710 additions and 885 deletions.
268 changes: 268 additions & 0 deletions .NET/Microsoft.Recognizers.Definitions/BaseCurrency.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Generation parameters:
// - DataFilename: Patterns\Base-Currency.yaml
// - Language: NULL
// - ClassName: BaseCurrency
// </auto-generated>
//------------------------------------------------------------------------------
namespace Microsoft.Recognizers.Definitions
{
using System;
using System.Collections.Generic;

public static class BaseCurrency
{
public static readonly Dictionary<string, string> CurrencyFractionMapping = new Dictionary<string, string>
{
{ "CNY", "FEN|JIAO" },
{ "__D", "CENT" },
{ "RUB", "KOPEK" },
{ "AFN", "PUL" },
{ "EUR", "CENT" },
{ "ALL", "QINDARKE" },
{ "_ALP", "PENNY" },
{ "GBP", "PENNY" },
{ "_GGP", "PENNY" },
{ "DZD", "SANTEEM" },
{ "AOA", "CENTIMO" },
{ "ARS", "CENTAVO" },
{ "AMD", "LUMA" },
{ "AWG", "CENT" },
{ "_AP", "PENNY" },
{ "SHP", "PENNY" },
{ "AUD", "CENT" },
{ "AZN", "QƏPIK" },
{ "BSD", "CENT" },
{ "BHD", "FILS" },
{ "BDT", "POISHA" },
{ "BBD", "CENT" },
{ "BYN", "KAPYEYKA" },
{ "BZD", "CENT" },
{ "XOF", "CENTIME" },
{ "BMD", "CENT" },
{ "BTN", "CHETRUM" },
{ "INR", "PAISA" },
{ "BOB", "CENTAVO" },
{ "USD", "CENT" },
{ "BAM", "FENING" },
{ "BWP", "THEBE" },
{ "BRL", "CENTAVO" },
{ "_BD", "CENT" },
{ "BND", "SEN" },
{ "SGD", "CENT" },
{ "BGN", "STOTINKA" },
{ "BIF", "CENTIME" },
{ "KHR", "SEN" },
{ "XAF", "CENTIME" },
{ "CAD", "CENT" },
{ "CVE", "CENTAVO" },
{ "KYD", "CENT" },
{ "CLP", "CENTAVO" },
{ "COP", "CENTAVO" },
{ "KMF", "CENTIME" },
{ "CDF", "CENTIME" },
{ "NZD", "CENT" },
{ "_CKD", "CENT" },
{ "CRC", "CENTIMO" },
{ "HRK", "LIPA" },
{ "CUC", "CENTAVO" },
{ "CUP", "CENTAVO" },
{ "CZK", "HALER" },
{ "DKK", "ØRE" },
{ "DJF", "CENTIME" },
{ "DOP", "CENTAVO" },
{ "EGP", "PIASTRE" },
{ "ERN", "CENT" },
{ "ETB", "SANTIM" },
{ "FKP", "PENNY" },
{ "_FOK", "OYRA" },
{ "FJD", "CENT" },
{ "XPF", "CENTIME" },
{ "GMD", "BUTUT" },
{ "GEL", "TETRI" },
{ "GHS", "PESEWA" },
{ "GIP", "PENNY" },
{ "GTQ", "CENTAVO" },
{ "GNF", "CENTIME" },
{ "GYD", "CENT" },
{ "HTG", "CENTIME" },
{ "HNL", "CENTAVO" },
{ "HKD", "CENT" },
{ "HUF", "FILLER" },
{ "ISK", "EYRIR" },
{ "IDR", "SEN" },
{ "IRR", "DINAR" },
{ "IQD", "FILS" },
{ "IMP", "PENNY" },
{ "ILS", "AGORA" },
{ "JMD", "CENT" },
{ "JPY", "SEN" },
{ "JEP", "PENNY" },
{ "JOD", "PIASTRE" },
{ "KZT", "TIIN" },
{ "KES", "CENT" },
{ "_KID", "CENT" },
{ "KPW", "CHON" },
{ "KRW", "JEON" },
{ "KWD", "FILS" },
{ "KGS", "TYIYN" },
{ "LAK", "ATT" },
{ "LBP", "PIASTRE" },
{ "LSL", "SENTE" },
{ "ZAR", "CENT" },
{ "LRD", "CENT" },
{ "LYD", "DIRHAM" },
{ "CHF", "RAPPEN" },
{ "MOP", "AVO" },
{ "MKD", "DENI" },
{ "MGA", "IRAIMBILANJA" },
{ "MWK", "TAMBALA" },
{ "MYR", "SEN" },
{ "MVR", "LAARI" },
{ "MRO", "KHOUMS" },
{ "MUR", "CENT" },
{ "MXN", "CENTAVO" },
{ "_MD", "CENT" },
{ "MDL", "BAN" },
{ "MNT", "MONGO" },
{ "MAD", "CENTIME" },
{ "MZN", "CENTAVO" },
{ "MMK", "PYA" },
{ "NAD", "CENT" },
{ "_ND", "CENT" },
{ "NPR", "PAISA" },
{ "NIO", "CENTAVO" },
{ "NGN", "KOBO" },
{ "_NID", "CENT" },
{ "TRY", "KURUS" },
{ "NOK", "ØRE" },
{ "OMR", "BAISA" },
{ "PKR", "PAISA" },
{ "_PD", "CENT" },
{ "PAB", "CENTESIMO" },
{ "PGK", "TOEA" },
{ "PYG", "CENTIMO" },
{ "PEN", "CENTIMO" },
{ "_PND", "CENT" },
{ "PLN", "GROSZ" },
{ "QAR", "DIRHAM" },
{ "RON", "BAN" },
{ "RWF", "CENTIME" },
{ "WST", "SENE" },
{ "STD", "CENTIMO" },
{ "SAR", "HALALA" },
{ "RSD", "PARA" },
{ "SCR", "CENT" },
{ "SLL", "CENT" },
{ "SBD", "CENT" },
{ "SOS", "CENT" },
{ "_SS", "CENT" },
{ "_SP", "PENNY" },
{ "SSP", "PIASTRE" },
{ "LKR", "CENT" },
{ "SDG", "PIASTRE" },
{ "SRD", "CENT" },
{ "SZL", "CENT" },
{ "SEK", "ORE" },
{ "SYP", "PIASTRE" },
{ "TWD", "CENT" },
{ "TJS", "DIRAM" },
{ "TZS", "CENT" },
{ "THB", "SATANG" },
{ "PRB", "KOPEK" },
{ "TTD", "CENT" },
{ "_TP", "PENNY" },
{ "TND", "MILLIME" },
{ "TMT", "TENNESI" },
{ "TVD", "CENT" },
{ "UGX", "CENT" },
{ "UAH", "KOPIYKA" },
{ "AED", "FILS" },
{ "UYU", "CENTESIMO" },
{ "VEF", "CENTIMO" },
{ "YER", "FILS" },
{ "ZMW", "NGWEE" }
};
public static readonly Dictionary<string, long> CurrencyFractionalRatios = new Dictionary<string, long>
{
{ "Kopek", 100 },
{ "Pul", 100 },
{ "Cent", 100 },
{ "Qindarkë", 100 },
{ "Penny", 100 },
{ "Santeem", 100 },
{ "Cêntimo", 100 },
{ "Centavo", 100 },
{ "Luma", 100 },
{ "Qəpik", 100 },
{ "Fils", 1000 },
{ "Poisha", 100 },
{ "Kapyeyka", 100 },
{ "Centime", 100 },
{ "Chetrum", 100 },
{ "Paisa", 100 },
{ "Fening", 100 },
{ "Thebe", 100 },
{ "Sen", 100 },
{ "Stotinka", 100 },
{ "Jiao", 10 },
{ "Fen", 100 },
{ "Céntimo", 100 },
{ "Lipa", 100 },
{ "Haléř", 100 },
{ "Øre", 100 },
{ "Piastre", 100 },
{ "Santim", 100 },
{ "Oyra", 100 },
{ "Butut", 100 },
{ "Tetri", 100 },
{ "Pesewa", 100 },
{ "Fillér", 100 },
{ "Eyrir", 100 },
{ "Dinar", 100 },
{ "Agora", 100 },
{ "Tïın", 100 },
{ "Chon", 100 },
{ "Jeon", 100 },
{ "Tyiyn", 100 },
{ "Att", 100 },
{ "Sente", 100 },
{ "Dirham", 1000 },
{ "Rappen", 100 },
{ "Avo", 100 },
{ "Deni", 100 },
{ "Iraimbilanja", 5 },
{ "Tambala", 100 },
{ "Laari", 100 },
{ "Khoums", 5 },
{ "Ban", 100 },
{ "Möngö", 100 },
{ "Pya", 100 },
{ "Kobo", 100 },
{ "Kuruş", 100 },
{ "Baisa", 1000 },
{ "Centésimo", 100 },
{ "Toea", 100 },
{ "Sentimo", 100 },
{ "Grosz", 100 },
{ "Sene", 100 },
{ "Halala", 100 },
{ "Para", 100 },
{ "Öre", 100 },
{ "Diram", 100 },
{ "Satang", 100 },
{ "Seniti", 100 },
{ "Millime", 1000 },
{ "Tennesi", 100 },
{ "Kopiyka", 100 },
{ "Tiyin", 100 },
{ "Hào", 10 },
{ "Ngwee", 100 }
};
}
}
7 changes: 7 additions & 0 deletions .NET/Microsoft.Recognizers.Definitions/BaseCurrency.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<#@ template debug="true" hostspecific="true" language="C#" #>
<#
this.DataFilename = @"Patterns\Base-Currency.yaml";
this.Language = null;
this.ClassName = "BaseCurrency";
#>
<#@ include file=".\CommonDefinitions.ttinclude"#>
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public static class NumbersWithUnitDefinitions
{ "Finnish markka", "芬兰马克" },
{ "Penni", "盆尼" }
};
public const string CompoundUnitConnectorRegex = @"(?<spacer>又|再)";
public static readonly Dictionary<string, string> CurrencyPrefixList = new Dictionary<string, string>
{
{ "Dollar", "$" },
Expand Down
Loading

0 comments on commit 4d8389e

Please sign in to comment.