@delali/narsil-react-native 0.3.1-next.155 → 0.3.1-next.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +144 -0
- package/NarsilReactNative.podspec +2 -2
- package/android/CMakeLists.txt +1 -1
- package/cpp/HybridNarsilCoreAnalysis.cpp +277 -0
- package/cpp/HybridNarsilCoreImpl.hpp +43 -0
- package/cpp/HybridNarsilCoreKeyword.cpp +253 -0
- package/cpp/HybridNarsilCoreMath.cpp +47 -0
- package/cpp/core/include/narsil_analysis.h +86 -0
- package/cpp/core/include/narsil_core.h +1 -1
- package/cpp/core/include/narsil_keyword.h +110 -0
- package/cpp/core/include/narsil_math.h +36 -0
- package/cpp/core/src/analysis/analyse.c +281 -0
- package/cpp/core/src/analysis/analyser.h +49 -0
- package/cpp/core/src/analysis/languages.c +79 -0
- package/cpp/core/src/analysis/languages.h +42 -0
- package/cpp/core/src/analysis/normalise.c +242 -0
- package/cpp/core/src/analysis/normalise.h +28 -0
- package/cpp/core/src/analysis/split.c +183 -0
- package/cpp/core/src/analysis/split.h +27 -0
- package/cpp/core/src/analysis/stop_words.c +82 -0
- package/cpp/core/src/analysis/stop_words.h +19 -0
- package/cpp/core/src/analysis/term_cache.c +88 -0
- package/cpp/core/src/analysis/term_cache.h +36 -0
- package/cpp/core/src/analysis/text.c +161 -0
- package/cpp/core/src/analysis/text.h +45 -0
- package/cpp/core/src/analysis/transform.c +103 -0
- package/cpp/core/src/analysis/unicode.c +252 -0
- package/cpp/core/src/analysis/unicode.h +54 -0
- package/cpp/core/src/internal.h +4 -0
- package/cpp/core/src/keyword/pass.h +117 -0
- package/cpp/core/src/keyword/prune.c +324 -0
- package/cpp/core/src/keyword/request.c +179 -0
- package/cpp/core/src/keyword/rows.c +83 -0
- package/cpp/core/src/keyword/rows.h +18 -0
- package/cpp/core/src/keyword/score.c +257 -0
- package/cpp/core/src/keyword/score.h +17 -0
- package/cpp/core/src/keyword/scratch.c +226 -0
- package/cpp/core/src/keyword/scratch.h +55 -0
- package/cpp/core/src/keyword/select.c +155 -0
- package/cpp/core/src/keyword/select.h +17 -0
- package/cpp/core/src/languages/bulgarian_stemmer.c +114 -0
- package/cpp/core/src/languages/data/albanian.c +54 -0
- package/cpp/core/src/languages/data/amharic.c +93 -0
- package/cpp/core/src/languages/data/arabic.c +146 -0
- package/cpp/core/src/languages/data/armenian.c +46 -0
- package/cpp/core/src/languages/data/azerbaijani.c +68 -0
- package/cpp/core/src/languages/data/bambara.c +48 -0
- package/cpp/core/src/languages/data/basque.c +62 -0
- package/cpp/core/src/languages/data/belarusian.c +56 -0
- package/cpp/core/src/languages/data/bengali.c +63 -0
- package/cpp/core/src/languages/data/bosnian.c +73 -0
- package/cpp/core/src/languages/data/breton.c +52 -0
- package/cpp/core/src/languages/data/bulgarian.c +144 -0
- package/cpp/core/src/languages/data/burmese.c +48 -0
- package/cpp/core/src/languages/data/catalan.c +84 -0
- package/cpp/core/src/languages/data/chinese.c +70 -0
- package/cpp/core/src/languages/data/croatian.c +72 -0
- package/cpp/core/src/languages/data/czech.c +72 -0
- package/cpp/core/src/languages/data/dagbani.c +88 -0
- package/cpp/core/src/languages/data/danish.c +56 -0
- package/cpp/core/src/languages/data/declarations.h +114 -0
- package/cpp/core/src/languages/data/dutch.c +58 -0
- package/cpp/core/src/languages/data/english.c +172 -0
- package/cpp/core/src/languages/data/esperanto.c +71 -0
- package/cpp/core/src/languages/data/estonian.c +417 -0
- package/cpp/core/src/languages/data/ewe.c +89 -0
- package/cpp/core/src/languages/data/faroese.c +54 -0
- package/cpp/core/src/languages/data/fijian.c +44 -0
- package/cpp/core/src/languages/data/finnish.c +100 -0
- package/cpp/core/src/languages/data/french.c +74 -0
- package/cpp/core/src/languages/data/ga.c +83 -0
- package/cpp/core/src/languages/data/galician.c +70 -0
- package/cpp/core/src/languages/data/georgian.c +57 -0
- package/cpp/core/src/languages/data/german.c +96 -0
- package/cpp/core/src/languages/data/greek.c +202 -0
- package/cpp/core/src/languages/data/guarani.c +110 -0
- package/cpp/core/src/languages/data/gujarati.c +90 -0
- package/cpp/core/src/languages/data/haitian-creole.c +54 -0
- package/cpp/core/src/languages/data/hausa.c +85 -0
- package/cpp/core/src/languages/data/hawaiian.c +50 -0
- package/cpp/core/src/languages/data/hebrew.c +85 -0
- package/cpp/core/src/languages/data/hindi.c +91 -0
- package/cpp/core/src/languages/data/hungarian.c +98 -0
- package/cpp/core/src/languages/data/icelandic.c +73 -0
- package/cpp/core/src/languages/data/igbo.c +90 -0
- package/cpp/core/src/languages/data/indonesian.c +296 -0
- package/cpp/core/src/languages/data/irish.c +60 -0
- package/cpp/core/src/languages/data/italian.c +107 -0
- package/cpp/core/src/languages/data/japanese.c +52 -0
- package/cpp/core/src/languages/data/kannada.c +60 -0
- package/cpp/core/src/languages/data/kazakh.c +57 -0
- package/cpp/core/src/languages/data/khmer.c +71 -0
- package/cpp/core/src/languages/data/kinyarwanda.c +54 -0
- package/cpp/core/src/languages/data/kirundi.c +53 -0
- package/cpp/core/src/languages/data/korean.c +74 -0
- package/cpp/core/src/languages/data/kurmanji.c +43 -0
- package/cpp/core/src/languages/data/kyrgyz.c +65 -0
- package/cpp/core/src/languages/data/lao.c +46 -0
- package/cpp/core/src/languages/data/latin.c +46 -0
- package/cpp/core/src/languages/data/latvian.c +75 -0
- package/cpp/core/src/languages/data/lingala.c +88 -0
- package/cpp/core/src/languages/data/lithuanian.c +65 -0
- package/cpp/core/src/languages/data/luxembourgish.c +80 -0
- package/cpp/core/src/languages/data/macedonian.c +286 -0
- package/cpp/core/src/languages/data/malagasy.c +51 -0
- package/cpp/core/src/languages/data/malay.c +184 -0
- package/cpp/core/src/languages/data/malayalam.c +64 -0
- package/cpp/core/src/languages/data/maltese.c +102 -0
- package/cpp/core/src/languages/data/maori.c +52 -0
- package/cpp/core/src/languages/data/marathi.c +62 -0
- package/cpp/core/src/languages/data/nepali.c +72 -0
- package/cpp/core/src/languages/data/norwegian.c +74 -0
- package/cpp/core/src/languages/data/oromo.c +51 -0
- package/cpp/core/src/languages/data/persian.c +150 -0
- package/cpp/core/src/languages/data/polish.c +111 -0
- package/cpp/core/src/languages/data/portuguese.c +91 -0
- package/cpp/core/src/languages/data/punjabi.c +80 -0
- package/cpp/core/src/languages/data/registry.c +116 -0
- package/cpp/core/src/languages/data/romanian.c +93 -0
- package/cpp/core/src/languages/data/russian.c +76 -0
- package/cpp/core/src/languages/data/samoan.c +47 -0
- package/cpp/core/src/languages/data/sanskrit.c +53 -0
- package/cpp/core/src/languages/data/scottish-gaelic.c +119 -0
- package/cpp/core/src/languages/data/serbian.c +84 -0
- package/cpp/core/src/languages/data/shona.c +55 -0
- package/cpp/core/src/languages/data/sinhala.c +78 -0
- package/cpp/core/src/languages/data/slovak.c +135 -0
- package/cpp/core/src/languages/data/slovenian.c +139 -0
- package/cpp/core/src/languages/data/sorani.c +55 -0
- package/cpp/core/src/languages/data/spanish.c +84 -0
- package/cpp/core/src/languages/data/swahili.c +59 -0
- package/cpp/core/src/languages/data/swedish.c +60 -0
- package/cpp/core/src/languages/data/tagalog.c +75 -0
- package/cpp/core/src/languages/data/tamil.c +69 -0
- package/cpp/core/src/languages/data/tatar.c +548 -0
- package/cpp/core/src/languages/data/telugu.c +54 -0
- package/cpp/core/src/languages/data/thai.c +46 -0
- package/cpp/core/src/languages/data/tibetan.c +55 -0
- package/cpp/core/src/languages/data/tigrinya.c +73 -0
- package/cpp/core/src/languages/data/tongan.c +47 -0
- package/cpp/core/src/languages/data/turkish.c +100 -0
- package/cpp/core/src/languages/data/twi.c +88 -0
- package/cpp/core/src/languages/data/ukrainian.c +99 -0
- package/cpp/core/src/languages/data/urdu.c +174 -0
- package/cpp/core/src/languages/data/vietnamese.c +88 -0
- package/cpp/core/src/languages/data/welsh.c +143 -0
- package/cpp/core/src/languages/data/wolof.c +51 -0
- package/cpp/core/src/languages/data/xhosa.c +56 -0
- package/cpp/core/src/languages/data/yoruba.c +93 -0
- package/cpp/core/src/languages/data/zulu.c +58 -0
- package/cpp/core/src/languages/marks.c +64 -0
- package/cpp/core/src/languages/rules.c +63 -0
- package/cpp/core/src/languages/rules.h +68 -0
- package/cpp/core/src/languages/sanskrit_stemmer.c +50 -0
- package/cpp/core/src/languages/scripts.c +143 -0
- package/cpp/core/src/languages/slovenian_stemmer.c +46 -0
- package/cpp/core/src/languages/snowball/api.c +52 -0
- package/cpp/core/src/languages/snowball/api.h +43 -0
- package/cpp/core/src/languages/snowball/arabic_stemmer.c +1506 -0
- package/cpp/core/src/languages/snowball/arabic_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/armenian_stemmer.c +523 -0
- package/cpp/core/src/languages/snowball/armenian_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/basque_stemmer.c +1089 -0
- package/cpp/core/src/languages/snowball/basque_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/catalan_stemmer.c +1380 -0
- package/cpp/core/src/languages/snowball/catalan_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/czech_stemmer.c +582 -0
- package/cpp/core/src/languages/snowball/czech_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/danish_stemmer.c +352 -0
- package/cpp/core/src/languages/snowball/danish_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/dutch_stemmer.c +1657 -0
- package/cpp/core/src/languages/snowball/dutch_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/english_stemmer.c +1019 -0
- package/cpp/core/src/languages/snowball/english_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/esperanto_stemmer.c +716 -0
- package/cpp/core/src/languages/snowball/esperanto_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/estonian_stemmer.c +1361 -0
- package/cpp/core/src/languages/snowball/estonian_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/finnish_stemmer.c +800 -0
- package/cpp/core/src/languages/snowball/finnish_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/french_stemmer.c +1217 -0
- package/cpp/core/src/languages/snowball/french_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/german_stemmer.c +567 -0
- package/cpp/core/src/languages/snowball/german_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/greek_stemmer.c +3450 -0
- package/cpp/core/src/languages/snowball/greek_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/hindi_stemmer.c +325 -0
- package/cpp/core/src/languages/snowball/hindi_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/hungarian_stemmer.c +742 -0
- package/cpp/core/src/languages/snowball/hungarian_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/indonesian_stemmer.c +443 -0
- package/cpp/core/src/languages/snowball/indonesian_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/irish_stemmer.c +428 -0
- package/cpp/core/src/languages/snowball/irish_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/italian_stemmer.c +983 -0
- package/cpp/core/src/languages/snowball/italian_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/lithuanian_stemmer.c +794 -0
- package/cpp/core/src/languages/snowball/lithuanian_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/nepali_stemmer.c +361 -0
- package/cpp/core/src/languages/snowball/nepali_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/norwegian_stemmer.c +332 -0
- package/cpp/core/src/languages/snowball/norwegian_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/persian_stemmer.c +538 -0
- package/cpp/core/src/languages/snowball/persian_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/polish_stemmer.c +501 -0
- package/cpp/core/src/languages/snowball/polish_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/portuguese_stemmer.c +866 -0
- package/cpp/core/src/languages/snowball/portuguese_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/romanian_stemmer.c +940 -0
- package/cpp/core/src/languages/snowball/romanian_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/russian_stemmer.c +598 -0
- package/cpp/core/src/languages/snowball/russian_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/serbian_stemmer.c +6765 -0
- package/cpp/core/src/languages/snowball/serbian_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/snowball_runtime.h +122 -0
- package/cpp/core/src/languages/snowball/spanish_stemmer.c +955 -0
- package/cpp/core/src/languages/snowball/spanish_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/swedish_stemmer.c +364 -0
- package/cpp/core/src/languages/snowball/swedish_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/tamil_stemmer.c +1305 -0
- package/cpp/core/src/languages/snowball/tamil_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/turkish_stemmer.c +1700 -0
- package/cpp/core/src/languages/snowball/turkish_stemmer.h +24 -0
- package/cpp/core/src/languages/snowball/utilities.c +716 -0
- package/cpp/core/src/languages/substitutions.c +131 -0
- package/cpp/core/src/languages/swahili_stemmer.c +85 -0
- package/cpp/core/src/languages/ukrainian_stemmer.c +168 -0
- package/cpp/core/src/locks.c +2 -15
- package/cpp/core/src/math/apply.c +44 -0
- package/cpp/core/src/math/fdlibm.h +16 -0
- package/cpp/core/src/math/inverse.c +242 -0
- package/cpp/core/src/math/log.c +90 -0
- package/cpp/core/src/math/reduce.c +325 -0
- package/cpp/core/src/math/trig.c +188 -0
- package/cpp/core/src/math/words.h +45 -0
- package/cpp/core/src/thread_yield.h +18 -0
- package/cpp/core/src/unicode/decompositions.c +310 -0
- package/cpp/core/src/unicode/lowercase.c +172 -0
- package/cpp/core/src/unicode/properties.c +214 -0
- package/cpp/core/src/workspace.c +5 -1
- package/lib/engine/analysis.d.ts +3 -0
- package/lib/engine/analysis.js +76 -0
- package/lib/engine/core.js +5 -0
- package/lib/engine/keyword.d.ts +3 -0
- package/lib/engine/keyword.js +25 -0
- package/lib/specs/core.nitro.d.ts +1 -0
- package/nitrogen/generated/shared/c++/HybridNarsilCoreSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridNarsilCoreSpec.hpp +1 -0
- package/package.json +4 -3
- package/src/engine/analysis.ts +87 -0
- package/src/engine/core.ts +6 -0
- package/src/engine/keyword.ts +26 -0
- package/src/specs/core.nitro.ts +1 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#include "../analysis/normalise.h"
|
|
2
|
+
#include "../analysis/text.h"
|
|
3
|
+
#include "rules.h"
|
|
4
|
+
|
|
5
|
+
#include <stddef.h>
|
|
6
|
+
#include <stdint.h>
|
|
7
|
+
|
|
8
|
+
#define COUNT_OF(array) (sizeof(array) / sizeof((array)[0]))
|
|
9
|
+
|
|
10
|
+
#define DELETE_UNIT(first, last) {(first), (last), 0, {0, 0}}
|
|
11
|
+
#define REPLACE_UNIT(first, last, unit) {(first), (last), 1, {(unit), 0}}
|
|
12
|
+
|
|
13
|
+
static const narsil_unit_substitution dagbani_substitutions[] = {
|
|
14
|
+
REPLACE_UNIT(0x03B5, 0x03B5, 0x025B),
|
|
15
|
+
REPLACE_UNIT(0x0511, 0x0511, 0x025B),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
static const narsil_unit_substitution ewe_substitutions[] = {
|
|
19
|
+
REPLACE_UNIT(0x00F0, 0x00F0, 0x0256),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
static const narsil_unit_substitution german_substitutions[] = {
|
|
23
|
+
{0x00DF, 0x00DF, 2, {0x0073, 0x0073}},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
static const narsil_unit_substitution guarani_substitutions[] = {
|
|
27
|
+
REPLACE_UNIT(0xA78C, 0xA78C, 0x0027),
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
static const narsil_unit_substitution hebrew_substitutions[] = {
|
|
31
|
+
DELETE_UNIT(0x0591, 0x05C7),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
static const narsil_unit_substitution persian_substitutions[] = {
|
|
35
|
+
REPLACE_UNIT(0x064A, 0x064A, 0x06CC), REPLACE_UNIT(0x0649, 0x0649, 0x06CC), REPLACE_UNIT(0x0643, 0x0643, 0x06A9),
|
|
36
|
+
DELETE_UNIT(0x0640, 0x0640), DELETE_UNIT(0x064B, 0x0652),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
static const narsil_unit_substitution romanian_substitutions[] = {
|
|
40
|
+
REPLACE_UNIT(0x015F, 0x015F, 0x0219),
|
|
41
|
+
REPLACE_UNIT(0x0163, 0x0163, 0x021B),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
static const narsil_unit_substitution serbian_substitutions[] = {
|
|
45
|
+
REPLACE_UNIT(0x0430, 0x0430, 0x0061), REPLACE_UNIT(0x0431, 0x0431, 0x0062), REPLACE_UNIT(0x0432, 0x0432, 0x0076),
|
|
46
|
+
REPLACE_UNIT(0x0433, 0x0433, 0x0067), REPLACE_UNIT(0x0434, 0x0434, 0x0064), REPLACE_UNIT(0x0435, 0x0435, 0x0065),
|
|
47
|
+
REPLACE_UNIT(0x0436, 0x0436, 0x017E), REPLACE_UNIT(0x0437, 0x0437, 0x007A), REPLACE_UNIT(0x0438, 0x0438, 0x0069),
|
|
48
|
+
REPLACE_UNIT(0x043A, 0x043A, 0x006B), REPLACE_UNIT(0x043B, 0x043B, 0x006C), REPLACE_UNIT(0x043C, 0x043C, 0x006D),
|
|
49
|
+
REPLACE_UNIT(0x043D, 0x043D, 0x006E), REPLACE_UNIT(0x043E, 0x043E, 0x006F), REPLACE_UNIT(0x043F, 0x043F, 0x0070),
|
|
50
|
+
REPLACE_UNIT(0x0440, 0x0440, 0x0072), REPLACE_UNIT(0x0441, 0x0441, 0x0073), REPLACE_UNIT(0x0442, 0x0442, 0x0074),
|
|
51
|
+
REPLACE_UNIT(0x0443, 0x0443, 0x0075), REPLACE_UNIT(0x0444, 0x0444, 0x0066), REPLACE_UNIT(0x0445, 0x0445, 0x0068),
|
|
52
|
+
REPLACE_UNIT(0x0446, 0x0446, 0x0063), REPLACE_UNIT(0x0447, 0x0447, 0x010D), REPLACE_UNIT(0x0448, 0x0448, 0x0161),
|
|
53
|
+
REPLACE_UNIT(0x0452, 0x0452, 0x0111), REPLACE_UNIT(0x0458, 0x0458, 0x006A), {0x0459, 0x0459, 2, {0x006C, 0x006A}},
|
|
54
|
+
{0x045A, 0x045A, 2, {0x006E, 0x006A}}, REPLACE_UNIT(0x045B, 0x045B, 0x0107), {0x045F, 0x045F, 2, {0x0064, 0x017E}},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
static const narsil_unit_substitution sinhala_substitutions[] = {
|
|
58
|
+
DELETE_UNIT(0x200D, 0x200D),
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
static const narsil_unit_substitution telugu_substitutions[] = {
|
|
62
|
+
DELETE_UNIT(0x200C, 0x200C),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
static const narsil_unit_substitution twi_substitutions[] = {
|
|
66
|
+
REPLACE_UNIT(0x03B5, 0x03B5, 0x025B),
|
|
67
|
+
REPLACE_UNIT(0x037B, 0x037B, 0x0254),
|
|
68
|
+
REPLACE_UNIT(0x2184, 0x2184, 0x0254),
|
|
69
|
+
REPLACE_UNIT(0x05DB, 0x05DB, 0x0254),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
int narsil_dagbani_normalise(const uint16_t *units, size_t length, narsil_text *out,
|
|
73
|
+
narsil_normalise_scratch *scratch) {
|
|
74
|
+
(void)scratch;
|
|
75
|
+
return narsil_substitute_units(units, length, dagbani_substitutions, COUNT_OF(dagbani_substitutions), out);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
int narsil_ewe_normalise(const uint16_t *units, size_t length, narsil_text *out, narsil_normalise_scratch *scratch) {
|
|
79
|
+
(void)scratch;
|
|
80
|
+
return narsil_substitute_units(units, length, ewe_substitutions, COUNT_OF(ewe_substitutions), out);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
int narsil_german_normalise(const uint16_t *units, size_t length, narsil_text *out, narsil_normalise_scratch *scratch) {
|
|
84
|
+
(void)scratch;
|
|
85
|
+
return narsil_substitute_units(units, length, german_substitutions, COUNT_OF(german_substitutions), out);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
int narsil_guarani_normalise(const uint16_t *units, size_t length, narsil_text *out,
|
|
89
|
+
narsil_normalise_scratch *scratch) {
|
|
90
|
+
(void)scratch;
|
|
91
|
+
return narsil_substitute_units(units, length, guarani_substitutions, COUNT_OF(guarani_substitutions), out);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
int narsil_hebrew_normalise(const uint16_t *units, size_t length, narsil_text *out, narsil_normalise_scratch *scratch) {
|
|
95
|
+
(void)scratch;
|
|
96
|
+
return narsil_substitute_units(units, length, hebrew_substitutions, COUNT_OF(hebrew_substitutions), out);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
int narsil_persian_normalise(const uint16_t *units, size_t length, narsil_text *out,
|
|
100
|
+
narsil_normalise_scratch *scratch) {
|
|
101
|
+
(void)scratch;
|
|
102
|
+
return narsil_substitute_units(units, length, persian_substitutions, COUNT_OF(persian_substitutions), out);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
int narsil_romanian_normalise(const uint16_t *units, size_t length, narsil_text *out,
|
|
106
|
+
narsil_normalise_scratch *scratch) {
|
|
107
|
+
(void)scratch;
|
|
108
|
+
return narsil_substitute_units(units, length, romanian_substitutions, COUNT_OF(romanian_substitutions), out);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
int narsil_serbian_normalise(const uint16_t *units, size_t length, narsil_text *out,
|
|
112
|
+
narsil_normalise_scratch *scratch) {
|
|
113
|
+
(void)scratch;
|
|
114
|
+
return narsil_substitute_units(units, length, serbian_substitutions, COUNT_OF(serbian_substitutions), out);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
int narsil_sinhala_normalise(const uint16_t *units, size_t length, narsil_text *out,
|
|
118
|
+
narsil_normalise_scratch *scratch) {
|
|
119
|
+
(void)scratch;
|
|
120
|
+
return narsil_substitute_units(units, length, sinhala_substitutions, COUNT_OF(sinhala_substitutions), out);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
int narsil_telugu_normalise(const uint16_t *units, size_t length, narsil_text *out, narsil_normalise_scratch *scratch) {
|
|
124
|
+
(void)scratch;
|
|
125
|
+
return narsil_substitute_units(units, length, telugu_substitutions, COUNT_OF(telugu_substitutions), out);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
int narsil_twi_normalise(const uint16_t *units, size_t length, narsil_text *out, narsil_normalise_scratch *scratch) {
|
|
129
|
+
(void)scratch;
|
|
130
|
+
return narsil_substitute_units(units, length, twi_substitutions, COUNT_OF(twi_substitutions), out);
|
|
131
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#include "../analysis/normalise.h"
|
|
2
|
+
#include "../analysis/text.h"
|
|
3
|
+
#include "rules.h"
|
|
4
|
+
|
|
5
|
+
#include <stddef.h>
|
|
6
|
+
#include <stdint.h>
|
|
7
|
+
#include <string.h>
|
|
8
|
+
|
|
9
|
+
#define MIN_STEMMED_UNITS 4U
|
|
10
|
+
#define MIN_REMAINING_UNITS 3U
|
|
11
|
+
#define COUNT_OF(array) (sizeof(array) / sizeof((array)[0]))
|
|
12
|
+
|
|
13
|
+
static const uint16_t *const subject_prefixes[] = {u"ni", u"tu", u"wa", u"vi", u"zi", u"li", u"ya", u"ku"};
|
|
14
|
+
static const uint16_t *const short_subject_prefixes[] = {u"u", u"a", u"i", u"m"};
|
|
15
|
+
static const uint16_t *const tense_markers[] = {u"na", u"li", u"ta", u"me", u"ki"};
|
|
16
|
+
static const uint16_t *const relative_markers[] = {u"cho", u"vyo", u"ye", u"zo", u"lo", u"yo", u"ko", u"po", u"mo"};
|
|
17
|
+
static const uint16_t *const negative_prefixes[] = {u"ha", u"si"};
|
|
18
|
+
static const uint16_t *const noun_class_prefixes[] = {u"wa", u"mi", u"ki", u"vi", u"ma"};
|
|
19
|
+
static const uint16_t *const short_noun_prefixes[] = {u"m", u"u"};
|
|
20
|
+
static const uint16_t *const long_suffixes[] = {u"isha", u"ika", u"ana", u"iwa", u"ewa",
|
|
21
|
+
u"aje", u"ane", u"eni", u"ini"};
|
|
22
|
+
static const uint16_t *const short_suffixes[] = {u"wa", u"ia", u"ea"};
|
|
23
|
+
static const uint16_t *const final_vowels[] = {u"a", u"i", u"e", u"u"};
|
|
24
|
+
|
|
25
|
+
typedef struct {
|
|
26
|
+
const uint16_t *units;
|
|
27
|
+
size_t length;
|
|
28
|
+
} word_view;
|
|
29
|
+
|
|
30
|
+
static int remove_prefix(word_view *word, const uint16_t *const *prefixes, size_t prefix_count) {
|
|
31
|
+
for (size_t i = 0; i < prefix_count; i++) {
|
|
32
|
+
size_t length = narsil_rule_length(prefixes[i]);
|
|
33
|
+
if (length <= word->length && word->length - length >= MIN_REMAINING_UNITS &&
|
|
34
|
+
memcmp(word->units, prefixes[i], length * sizeof(uint16_t)) == 0) {
|
|
35
|
+
word->units += length;
|
|
36
|
+
word->length -= length;
|
|
37
|
+
return 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static int remove_suffix(word_view *word, const uint16_t *const *suffixes, size_t suffix_count) {
|
|
44
|
+
for (size_t i = 0; i < suffix_count; i++) {
|
|
45
|
+
size_t length = narsil_rule_length(suffixes[i]);
|
|
46
|
+
if (length <= word->length && word->length - length >= MIN_REMAINING_UNITS &&
|
|
47
|
+
memcmp(word->units + (word->length - length), suffixes[i], length * sizeof(uint16_t)) == 0) {
|
|
48
|
+
word->length -= length;
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static void remove_prefixes(word_view *word) {
|
|
56
|
+
size_t original_length = word->length;
|
|
57
|
+
remove_prefix(word, negative_prefixes, COUNT_OF(negative_prefixes));
|
|
58
|
+
int subject_removed = remove_prefix(word, subject_prefixes, COUNT_OF(subject_prefixes));
|
|
59
|
+
if (!subject_removed) {
|
|
60
|
+
subject_removed = remove_prefix(word, short_subject_prefixes, COUNT_OF(short_subject_prefixes));
|
|
61
|
+
}
|
|
62
|
+
if (subject_removed) {
|
|
63
|
+
remove_prefix(word, tense_markers, COUNT_OF(tense_markers));
|
|
64
|
+
remove_prefix(word, relative_markers, COUNT_OF(relative_markers));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
remove_prefix(word, noun_class_prefixes, COUNT_OF(noun_class_prefixes));
|
|
68
|
+
if (word->length == original_length) { remove_prefix(word, short_noun_prefixes, COUNT_OF(short_noun_prefixes)); }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static void remove_suffixes(word_view *word) {
|
|
72
|
+
if (remove_suffix(word, long_suffixes, COUNT_OF(long_suffixes))) { return; }
|
|
73
|
+
if (remove_suffix(word, short_suffixes, COUNT_OF(short_suffixes))) { return; }
|
|
74
|
+
remove_suffix(word, final_vowels, COUNT_OF(final_vowels));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
int narsil_swahili_stem(const uint16_t *units, size_t length, narsil_text *out, narsil_normalise_scratch *scratch) {
|
|
78
|
+
(void)scratch;
|
|
79
|
+
word_view word = {units, length};
|
|
80
|
+
if (length >= MIN_STEMMED_UNITS) {
|
|
81
|
+
remove_prefixes(&word);
|
|
82
|
+
remove_suffixes(&word);
|
|
83
|
+
}
|
|
84
|
+
return narsil_text_assign(out, word.units, word.length);
|
|
85
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#include "../analysis/normalise.h"
|
|
2
|
+
#include "../analysis/text.h"
|
|
3
|
+
#include "rules.h"
|
|
4
|
+
|
|
5
|
+
#include <stddef.h>
|
|
6
|
+
#include <stdint.h>
|
|
7
|
+
#include <string.h>
|
|
8
|
+
|
|
9
|
+
#define NO_MATCH SIZE_MAX
|
|
10
|
+
#define LIST_OF(array) {(array), sizeof(array) / sizeof((array)[0])}
|
|
11
|
+
#define CYRILLIC_A 0x0430U
|
|
12
|
+
#define CYRILLIC_YA 0x044FU
|
|
13
|
+
|
|
14
|
+
typedef struct {
|
|
15
|
+
const uint16_t *units;
|
|
16
|
+
size_t length;
|
|
17
|
+
size_t rv;
|
|
18
|
+
size_t r2;
|
|
19
|
+
} ukrainian_word;
|
|
20
|
+
|
|
21
|
+
typedef struct {
|
|
22
|
+
const uint16_t *const *suffixes;
|
|
23
|
+
size_t count;
|
|
24
|
+
} suffix_list;
|
|
25
|
+
|
|
26
|
+
static const uint16_t vowels[] = {0x0430, 0x0435, 0x0438, 0x043E, 0x0443, 0x044E, 0x044F, 0x0456, 0x0457, 0x0454};
|
|
27
|
+
|
|
28
|
+
static const uint16_t *const perfective_gerund_after_a_suffixes[] = {u"вшись", u"вши", u"в"};
|
|
29
|
+
static const uint16_t *const perfective_gerund_suffixes[] = {u"івшись", u"ивши", u"ів"};
|
|
30
|
+
static const uint16_t *const reflexive_suffixes[] = {u"ся", u"сь"};
|
|
31
|
+
static const uint16_t *const adjective_suffixes[] = {
|
|
32
|
+
u"ими", u"ого", u"ому", u"ій", u"ий", u"їй", u"ою", u"ее", u"іе", u"іє", u"ие", u"ої", u"їй",
|
|
33
|
+
u"ем", u"ім", u"ом", u"им", u"их", u"іх", u"ую", u"юю", u"ая", u"яя", u"ое", u"еє",
|
|
34
|
+
};
|
|
35
|
+
static const uint16_t *const participle_after_a_suffixes[] = {u"ем", u"нн", u"вш", u"ющ", u"щ"};
|
|
36
|
+
static const uint16_t *const participle_suffixes[] = {u"івш", u"ивш", u"уюч", u"ующ"};
|
|
37
|
+
static const uint16_t *const verb_after_a_suffixes[] = {
|
|
38
|
+
u"ете", u"йте", u"ешь", u"нно", u"ла", u"на", u"ли", u"ем", u"ло",
|
|
39
|
+
u"но", u"ет", u"ют", u"ни", u"ть", u"й", u"л", u"н",
|
|
40
|
+
};
|
|
41
|
+
static const uint16_t *const verb_suffixes[] = {
|
|
42
|
+
u"ейте", u"уйте", u"ують", u"ила", u"ила", u"ена", u"іте", u"ите", u"или", u"ило", u"ено", u"ять", u"ить",
|
|
43
|
+
u"іть", u"ішь", u"ей", u"уй", u"ив", u"ил", u"ім", u"им", u"ен", u"ує", u"ую", u"ю",
|
|
44
|
+
};
|
|
45
|
+
static const uint16_t *const noun_suffixes[] = {
|
|
46
|
+
u"іями", u"ями", u"іям", u"ієм", u"ією", u"ами", u"еві", u"ові", u"ів", u"їв", u"ій", u"ей", u"ем",
|
|
47
|
+
u"єм", u"єю", u"ов", u"ой", u"ом", u"ою", u"ію", u"ью", u"ія", u"ья", u"ям", u"ях", u"ах",
|
|
48
|
+
u"ам", u"а", u"е", u"є", u"і", u"ї", u"и", u"й", u"о", u"у", u"ь", u"ю", u"я",
|
|
49
|
+
};
|
|
50
|
+
static const uint16_t *const derivational_suffixes[] = {u"ість", u"ость", u"іст", u"ост"};
|
|
51
|
+
|
|
52
|
+
static const suffix_list perfective_gerund_after_a = LIST_OF(perfective_gerund_after_a_suffixes);
|
|
53
|
+
static const suffix_list perfective_gerund = LIST_OF(perfective_gerund_suffixes);
|
|
54
|
+
static const suffix_list reflexive = LIST_OF(reflexive_suffixes);
|
|
55
|
+
static const suffix_list adjective = LIST_OF(adjective_suffixes);
|
|
56
|
+
static const suffix_list participle_after_a = LIST_OF(participle_after_a_suffixes);
|
|
57
|
+
static const suffix_list participle = LIST_OF(participle_suffixes);
|
|
58
|
+
static const suffix_list verb_after_a = LIST_OF(verb_after_a_suffixes);
|
|
59
|
+
static const suffix_list verb = LIST_OF(verb_suffixes);
|
|
60
|
+
static const suffix_list noun = LIST_OF(noun_suffixes);
|
|
61
|
+
static const suffix_list derivational = LIST_OF(derivational_suffixes);
|
|
62
|
+
|
|
63
|
+
static int is_vowel(uint16_t unit) {
|
|
64
|
+
for (size_t i = 0; i < sizeof(vowels) / sizeof(vowels[0]); i++) {
|
|
65
|
+
if (vowels[i] == unit) { return 1; }
|
|
66
|
+
}
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static size_t vowel_then_consonant_after(const ukrainian_word *word, size_t from) {
|
|
71
|
+
for (size_t i = from; i < word->length; i++) {
|
|
72
|
+
if (!is_vowel(word->units[i]) && is_vowel(word->units[i - 1])) { return i + 1; }
|
|
73
|
+
}
|
|
74
|
+
return word->length;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static ukrainian_word regions_of(const uint16_t *units, size_t length) {
|
|
78
|
+
ukrainian_word word = {units, length, length, length};
|
|
79
|
+
for (size_t i = 0; i < length; i++) {
|
|
80
|
+
if (is_vowel(units[i])) {
|
|
81
|
+
word.rv = i + 1;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
size_t region_one = vowel_then_consonant_after(&word, 1);
|
|
86
|
+
word.r2 = vowel_then_consonant_after(&word, region_one + 1);
|
|
87
|
+
return word;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static size_t strip(const ukrainian_word *word, size_t length, const uint16_t *suffix, size_t region) {
|
|
91
|
+
size_t suffix_length = narsil_rule_length(suffix);
|
|
92
|
+
if (suffix_length > length || length - suffix_length < region) { return NO_MATCH; }
|
|
93
|
+
if (memcmp(word->units + (length - suffix_length), suffix, suffix_length * sizeof(uint16_t)) != 0) {
|
|
94
|
+
return NO_MATCH;
|
|
95
|
+
}
|
|
96
|
+
return length - suffix_length;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static size_t strip_first(const ukrainian_word *word, size_t length, suffix_list list, size_t region) {
|
|
100
|
+
for (size_t i = 0; i < list.count; i++) {
|
|
101
|
+
size_t stripped = strip(word, length, list.suffixes[i], region);
|
|
102
|
+
if (stripped != NO_MATCH) { return stripped; }
|
|
103
|
+
}
|
|
104
|
+
return NO_MATCH;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static size_t strip_after_a(const ukrainian_word *word, size_t length, suffix_list list) {
|
|
108
|
+
for (size_t i = 0; i < list.count; i++) {
|
|
109
|
+
size_t stripped = strip(word, length, list.suffixes[i], word->rv);
|
|
110
|
+
if (stripped != NO_MATCH && stripped > 0 &&
|
|
111
|
+
(word->units[stripped - 1] == CYRILLIC_A || word->units[stripped - 1] == CYRILLIC_YA)) {
|
|
112
|
+
return stripped;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return NO_MATCH;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static size_t strip_perfective_gerund(const ukrainian_word *word, size_t length) {
|
|
119
|
+
size_t stripped = strip_after_a(word, length, perfective_gerund_after_a);
|
|
120
|
+
if (stripped != NO_MATCH) { return stripped; }
|
|
121
|
+
return strip_first(word, length, perfective_gerund, word->rv);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static size_t strip_adjectival(const ukrainian_word *word, size_t length) {
|
|
125
|
+
size_t adjective_length = strip_first(word, length, adjective, word->rv);
|
|
126
|
+
if (adjective_length == NO_MATCH) { return NO_MATCH; }
|
|
127
|
+
size_t stripped = strip_after_a(word, adjective_length, participle_after_a);
|
|
128
|
+
if (stripped != NO_MATCH) { return stripped; }
|
|
129
|
+
stripped = strip_first(word, adjective_length, participle, word->rv);
|
|
130
|
+
return stripped != NO_MATCH ? stripped : adjective_length;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static size_t strip_verb(const ukrainian_word *word, size_t length) {
|
|
134
|
+
size_t stripped = strip_after_a(word, length, verb_after_a);
|
|
135
|
+
if (stripped != NO_MATCH) { return stripped; }
|
|
136
|
+
return strip_first(word, length, verb, word->rv);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static size_t strip_inflection(const ukrainian_word *word) {
|
|
140
|
+
size_t stripped = strip_perfective_gerund(word, word->length);
|
|
141
|
+
if (stripped != NO_MATCH) { return stripped; }
|
|
142
|
+
size_t base = strip_first(word, word->length, reflexive, word->rv);
|
|
143
|
+
if (base == NO_MATCH) { base = word->length; }
|
|
144
|
+
stripped = strip_adjectival(word, base);
|
|
145
|
+
if (stripped == NO_MATCH) { stripped = strip_verb(word, base); }
|
|
146
|
+
if (stripped == NO_MATCH) { stripped = strip_first(word, base, noun, word->rv); }
|
|
147
|
+
return stripped != NO_MATCH ? stripped : base;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
static size_t strip_superlative_and_soft_sign(const ukrainian_word *word, size_t length) {
|
|
151
|
+
size_t stripped = strip(word, length, u"ейше", word->rv);
|
|
152
|
+
if (stripped == NO_MATCH) { stripped = strip(word, length, u"ейш", word->rv); }
|
|
153
|
+
if (stripped == NO_MATCH && strip(word, length, u"нн", word->rv) != NO_MATCH) { stripped = length - 1; }
|
|
154
|
+
if (stripped == NO_MATCH) { stripped = strip(word, length, u"ь", word->rv); }
|
|
155
|
+
return stripped != NO_MATCH ? stripped : length;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
int narsil_ukrainian_stem(const uint16_t *units, size_t length, narsil_text *out, narsil_normalise_scratch *scratch) {
|
|
159
|
+
(void)scratch;
|
|
160
|
+
ukrainian_word word = regions_of(units, length);
|
|
161
|
+
size_t stemmed = strip_inflection(&word);
|
|
162
|
+
size_t without_i = strip(&word, stemmed, u"и", word.rv);
|
|
163
|
+
if (without_i != NO_MATCH) { stemmed = without_i; }
|
|
164
|
+
size_t derived = strip_first(&word, stemmed, derivational, word.r2);
|
|
165
|
+
if (derived != NO_MATCH) { stemmed = derived; }
|
|
166
|
+
stemmed = strip_superlative_and_soft_sign(&word, stemmed);
|
|
167
|
+
return narsil_text_assign(out, units, stemmed);
|
|
168
|
+
}
|
package/cpp/core/src/locks.c
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "internal.h"
|
|
2
|
+
#include "thread_yield.h"
|
|
2
3
|
|
|
3
4
|
#include "../include/narsil_core.h"
|
|
4
5
|
|
|
@@ -6,31 +7,17 @@
|
|
|
6
7
|
#include <stddef.h>
|
|
7
8
|
#include <stdint.h>
|
|
8
9
|
|
|
9
|
-
#ifdef _WIN32
|
|
10
|
-
#include <windows.h>
|
|
11
|
-
#else
|
|
12
|
-
#include <sched.h>
|
|
13
|
-
#endif
|
|
14
|
-
|
|
15
10
|
#define LOCK_SPIN_ITERATIONS 128
|
|
16
11
|
#define LIST_COUNT_WORDS 1
|
|
17
12
|
#define LOCK_FREE 0
|
|
18
13
|
#define LOCK_HELD_ALONE (-1)
|
|
19
14
|
|
|
20
|
-
static inline void yield_thread(void) {
|
|
21
|
-
#ifdef _WIN32
|
|
22
|
-
SwitchToThread();
|
|
23
|
-
#else
|
|
24
|
-
sched_yield();
|
|
25
|
-
#endif
|
|
26
|
-
}
|
|
27
|
-
|
|
28
15
|
static inline void wait_for_the_lock(uint32_t *waits) {
|
|
29
16
|
if (*waits < LOCK_SPIN_ITERATIONS) {
|
|
30
17
|
*waits += 1;
|
|
31
18
|
return;
|
|
32
19
|
}
|
|
33
|
-
|
|
20
|
+
narsil_yield_thread();
|
|
34
21
|
}
|
|
35
22
|
|
|
36
23
|
static inline uint32_t held_index(uint32_t thread_slot, uint32_t kind) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#include "fdlibm.h"
|
|
2
|
+
|
|
3
|
+
#include "../../include/narsil_core.h"
|
|
4
|
+
#include "../../include/narsil_math.h"
|
|
5
|
+
|
|
6
|
+
#include <stddef.h>
|
|
7
|
+
|
|
8
|
+
typedef double (*unary_function)(double value);
|
|
9
|
+
|
|
10
|
+
static unary_function unary_of(narsil_math_function function) {
|
|
11
|
+
switch (function) {
|
|
12
|
+
case NARSIL_MATH_LOG:
|
|
13
|
+
return fdlibm_log;
|
|
14
|
+
case NARSIL_MATH_SIN:
|
|
15
|
+
return fdlibm_sin;
|
|
16
|
+
case NARSIL_MATH_COS:
|
|
17
|
+
return fdlibm_cos;
|
|
18
|
+
case NARSIL_MATH_TAN:
|
|
19
|
+
return fdlibm_tan;
|
|
20
|
+
case NARSIL_MATH_ASIN:
|
|
21
|
+
return fdlibm_asin;
|
|
22
|
+
case NARSIL_MATH_ATAN:
|
|
23
|
+
return fdlibm_atan;
|
|
24
|
+
default:
|
|
25
|
+
return NULL;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
narsil_status narsil_math_apply(narsil_math_function function, const narsil_math_batch *batch) {
|
|
30
|
+
if (batch == NULL || (batch->count > 0 && (batch->first == NULL || batch->results == NULL))) {
|
|
31
|
+
return NARSIL_INVALID_ARGUMENT;
|
|
32
|
+
}
|
|
33
|
+
if (function == NARSIL_MATH_ATAN2) {
|
|
34
|
+
if (batch->count > 0 && batch->second == NULL) { return NARSIL_INVALID_ARGUMENT; }
|
|
35
|
+
for (size_t index = 0; index < batch->count; index++) {
|
|
36
|
+
batch->results[index] = fdlibm_atan2(batch->first[index], batch->second[index]);
|
|
37
|
+
}
|
|
38
|
+
return NARSIL_OK;
|
|
39
|
+
}
|
|
40
|
+
unary_function apply = unary_of(function);
|
|
41
|
+
if (apply == NULL) { return NARSIL_INVALID_ARGUMENT; }
|
|
42
|
+
for (size_t index = 0; index < batch->count; index++) { batch->results[index] = apply(batch->first[index]); }
|
|
43
|
+
return NARSIL_OK;
|
|
44
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#ifndef NARSIL_MATH_FDLIBM_H
|
|
2
|
+
#define NARSIL_MATH_FDLIBM_H
|
|
3
|
+
|
|
4
|
+
#include <stdint.h>
|
|
5
|
+
|
|
6
|
+
double fdlibm_log(double value);
|
|
7
|
+
double fdlibm_sin(double value);
|
|
8
|
+
double fdlibm_cos(double value);
|
|
9
|
+
double fdlibm_tan(double value);
|
|
10
|
+
double fdlibm_asin(double value);
|
|
11
|
+
double fdlibm_atan(double value);
|
|
12
|
+
double fdlibm_atan2(double rise, double run);
|
|
13
|
+
|
|
14
|
+
int32_t fdlibm_rem_pio2(double value, double *out);
|
|
15
|
+
|
|
16
|
+
#endif
|