Skip to content

Commit b12101d

Browse files
aitelintaitelint
andauthored
[ES Currency] Fix $$ USD Million not recognized as well as $$ MXN$ not recognized (#2889) (#2954)
Co-authored-by: aitelint <Fabrizio.Sorba@telusinternational.com>
1 parent 31bd8dd commit b12101d

4 files changed

Lines changed: 192 additions & 3 deletions

File tree

.NET/Microsoft.Recognizers.Definitions.Common/Spanish/NumbersWithUnitDefinitions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,11 @@ public static class NumbersWithUnitDefinitions
642642
{ @"Satoshi", @"SATOSHI" }
643643
};
644644
public const string CompoundUnitConnectorRegex = @"(?<spacer>y|con)";
645+
public const string MultiplierRegex = @"\s*\b(((mil\s+)?mi|bi|cuatri|quinti|sexti|septi)ll[oó]n|mil)(es)?\b";
645646
public static readonly Dictionary<string, string> CurrencyPrefixList = new Dictionary<string, string>
646647
{
647648
{ @"Dobra", @"db|std" },
648-
{ @"Dólar", @"$" },
649+
{ @"Dólar", @"$|dólar|dólares|dolar|dolares" },
649650
{ @"Dólar estadounidense", @"us$|u$d|usd" },
650651
{ @"Dólar del Caribe Oriental", @"ec$|xcd" },
651652
{ @"Dólar australiano", @"a$|aud" },

.NET/Microsoft.Recognizers.Text.NumberWithUnit/Spanish/Extractors/SpanishNumberWithUnitExtractorConfiguration.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public abstract class SpanishNumberWithUnitExtractorConfiguration : INumberWithU
2626
private static readonly Regex NonUnitsRegex =
2727
new Regex(BaseUnits.PmNonUnitRegex, RegexFlags);
2828

29+
private static readonly Regex NumberMultiplierRegex =
30+
new Regex(NumbersWithUnitDefinitions.MultiplierRegex, RegexFlags);
31+
2932
protected SpanishNumberWithUnitExtractorConfiguration(CultureInfo ci)
3033
{
3134
this.CultureInfo = ci;
@@ -59,7 +62,7 @@ protected SpanishNumberWithUnitExtractorConfiguration(CultureInfo ci)
5962

6063
public virtual Regex AmbiguousUnitNumberMultiplierRegex => null;
6164

62-
public Regex MultiplierRegex => null;
65+
public Regex MultiplierRegex => NumberMultiplierRegex;
6366

6467
public Dictionary<Regex, Regex> AmbiguityFiltersDict { get; } = null;
6568

Patterns/Spanish/Spanish-NumbersWithUnit.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,11 +867,13 @@ FractionalUnitNameToCodeMap: !dictionary
867867
Satoshi: SATOSHI
868868
CompoundUnitConnectorRegex: !simpleRegex
869869
def: (?<spacer>y|con)
870+
MultiplierRegex: !simpleRegex
871+
def: \s*\b(((mil\s+)?mi|bi|cuatri|quinti|sexti|septi)ll[oó]n|mil)(es)?\b
870872
CurrencyPrefixList: !dictionary
871873
types: [ string, string ]
872874
entries:
873875
Dobra: db|std
874-
Dólar: $
876+
Dólar: $|dólar|dólares|dolar|dolares
875877
Dólar estadounidense: us$|u$d|usd
876878
Dólar del Caribe Oriental: ec$|xcd
877879
Dólar australiano: a$|aud

Specs/NumberWithUnit/Spanish/CurrencyModel.json

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,5 +1731,188 @@
17311731
"End": 5
17321732
}
17331733
]
1734+
},
1735+
{
1736+
"Input": "Perdieron 75 USD millones en los últimos tres años.",
1737+
"NotSupported": "java, javascript, python",
1738+
"Results": [
1739+
{
1740+
"Text": "75 usd millones",
1741+
"TypeName": "currency",
1742+
"Resolution": {
1743+
"value": "75000000",
1744+
"unit": "Dólar estadounidense",
1745+
"isoCurrency": "USD"
1746+
},
1747+
"Start": 10,
1748+
"End": 24
1749+
}
1750+
]
1751+
},
1752+
{
1753+
"Input": "Los precios del acuerdo comienzan en dólar 22,5 millones.",
1754+
"NotSupported": "java, javascript, python",
1755+
"Results": [
1756+
{
1757+
"Text": "dólar 22,5 millones",
1758+
"TypeName": "currency",
1759+
"Resolution": {
1760+
"value": "22500000",
1761+
"unit": "Dólar"
1762+
},
1763+
"Start": 37,
1764+
"End": 55
1765+
}
1766+
]
1767+
},
1768+
{
1769+
"Input": "Los precios del acuerdo comienzan en dólar 22500000.",
1770+
"NotSupported": "java, javascript, python",
1771+
"Results": [
1772+
{
1773+
"Text": "dólar 22500000",
1774+
"TypeName": "currency",
1775+
"Resolution": {
1776+
"value": "22500000",
1777+
"unit": "Dólar"
1778+
},
1779+
"Start": 37,
1780+
"End": 50
1781+
}
1782+
]
1783+
},
1784+
{
1785+
"Input": "Por 15 dolares 50 puedes almorzar y cenar",
1786+
"NotSupported": "java, javascript, python",
1787+
"Results": [
1788+
{
1789+
"Text": "15 dolares 50",
1790+
"TypeName": "currency",
1791+
"Resolution": {
1792+
"value": "15,5",
1793+
"unit": "Dólar"
1794+
},
1795+
"Start": 4,
1796+
"End": 16
1797+
}
1798+
]
1799+
},
1800+
{
1801+
"Input": "Por 15 USD 50 puedes almorzar y cenar",
1802+
"NotSupported": "java, javascript, python",
1803+
"Results": [
1804+
{
1805+
"Text": "15 usd 50",
1806+
"TypeName": "currency",
1807+
"Resolution": {
1808+
"value": "15,5",
1809+
"unit": "Dólar estadounidense",
1810+
"isoCurrency": "USD"
1811+
},
1812+
"Start": 4,
1813+
"End": 12
1814+
}
1815+
]
1816+
},
1817+
{
1818+
"Input": "Pagaron 75 USD millones, pero el precio en realidad fue de 50 millones USD. Y si tuvieran otros 15 USD 50, habrían pagado 80 USD millones.",
1819+
"NotSupported": "java, javascript, python",
1820+
"Results": [
1821+
{
1822+
"Text": "75 usd millones",
1823+
"TypeName": "currency",
1824+
"Resolution": {
1825+
"value": "75000000",
1826+
"unit": "Dólar estadounidense",
1827+
"isoCurrency": "USD"
1828+
},
1829+
"Start": 8,
1830+
"End": 22
1831+
},
1832+
{
1833+
"Text": "50 millones usd",
1834+
"TypeName": "currency",
1835+
"Resolution": {
1836+
"value": "50000000",
1837+
"unit": "Dólar estadounidense",
1838+
"isoCurrency": "USD"
1839+
},
1840+
"Start": 59,
1841+
"End": 73
1842+
},
1843+
{
1844+
"Text": "15 usd 50",
1845+
"TypeName": "currency",
1846+
"Resolution": {
1847+
"value": "15,5",
1848+
"unit": "Dólar estadounidense",
1849+
"isoCurrency": "USD"
1850+
},
1851+
"Start": 96,
1852+
"End": 104
1853+
},
1854+
{
1855+
"Text": "80 usd millones",
1856+
"TypeName": "currency",
1857+
"Resolution": {
1858+
"value": "80000000",
1859+
"unit": "Dólar estadounidense",
1860+
"isoCurrency": "USD"
1861+
},
1862+
"Start": 122,
1863+
"End": 136
1864+
}
1865+
]
1866+
},
1867+
{
1868+
"Input": "El cheque equivalía a 125 USD millones",
1869+
"NotSupported": "java, javascript, python",
1870+
"Results": [
1871+
{
1872+
"Text": "125 usd millones",
1873+
"TypeName": "currency",
1874+
"Resolution": {
1875+
"value": "125000000",
1876+
"unit": "Dólar estadounidense",
1877+
"isoCurrency": "USD"
1878+
},
1879+
"Start": 22,
1880+
"End": 37
1881+
}
1882+
]
1883+
},
1884+
{
1885+
"Input": "Obtén 2 meses por MXN$ 20",
1886+
"NotSupported": "java, javascript, python",
1887+
"Results": [
1888+
{
1889+
"Text": "mxn$ 20",
1890+
"TypeName": "currency",
1891+
"Resolution": {
1892+
"value": "20",
1893+
"unit": "Peso mexicano",
1894+
"isoCurrency": "MXN"
1895+
},
1896+
"Start": 18,
1897+
"End": 24
1898+
}
1899+
]
1900+
},
1901+
{
1902+
"Input": "Obtén 2 meses por 20 MXN$",
1903+
"NotSupported": "java, javascript, python",
1904+
"Results": [
1905+
{
1906+
"Text": "20 mxn$",
1907+
"TypeName": "currency",
1908+
"Resolution": {
1909+
"value": "20",
1910+
"unit": "Peso mexicano",
1911+
"isoCurrency": "MXN"
1912+
},
1913+
"Start": 18,
1914+
"End": 24
1915+
}
1916+
]
17341917
}
17351918
]

0 commit comments

Comments
 (0)