cld3 3.4.4 → 3.5.1

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -1
  3. data/README.md +4 -15
  4. data/cld3.gemspec +7 -7
  5. data/ext/cld3/cld_3/protos/feature_extractor.pb.h +100 -0
  6. data/ext/cld3/cld_3/protos/sentence.pb.h +35 -0
  7. data/ext/cld3/cld_3/protos/task_spec.pb.h +106 -0
  8. data/ext/cld3/extconf.rb +2 -12
  9. data/ext/cld3/getonescriptspan.cc +0 -2
  10. data/ext/cld3/nnet_language_identifier_c.cc +162 -70
  11. data/lib/cld3.rb +15 -100
  12. data/sig/cld3.rbs +2 -0
  13. metadata +20 -74
  14. data/ext/cld3/Makefile +0 -267
  15. data/ext/cld3/base.o +0 -0
  16. data/ext/cld3/embedding_feature_extractor.o +0 -0
  17. data/ext/cld3/embedding_network.o +0 -0
  18. data/ext/cld3/feature_extractor.o +0 -0
  19. data/ext/cld3/feature_extractor.pb.o +0 -0
  20. data/ext/cld3/feature_extractor.proto +0 -50
  21. data/ext/cld3/feature_types.o +0 -0
  22. data/ext/cld3/fixunicodevalue.o +0 -0
  23. data/ext/cld3/fml_parser.o +0 -0
  24. data/ext/cld3/generated_entities.o +0 -0
  25. data/ext/cld3/generated_ulscript.o +0 -0
  26. data/ext/cld3/getonescriptspan.o +0 -0
  27. data/ext/cld3/lang_id_nn_params.o +0 -0
  28. data/ext/cld3/language_identifier_features.o +0 -0
  29. data/ext/cld3/libcld3.def +0 -8
  30. data/ext/cld3/libcld3.so +0 -0
  31. data/ext/cld3/mkmf.log +0 -37
  32. data/ext/cld3/nnet_language_identifier.o +0 -0
  33. data/ext/cld3/nnet_language_identifier_c.o +0 -0
  34. data/ext/cld3/offsetmap.o +0 -0
  35. data/ext/cld3/registry.o +0 -0
  36. data/ext/cld3/relevant_script_feature.o +0 -0
  37. data/ext/cld3/sentence.pb.o +0 -0
  38. data/ext/cld3/sentence.proto +0 -77
  39. data/ext/cld3/sentence_features.o +0 -0
  40. data/ext/cld3/task_context.o +0 -0
  41. data/ext/cld3/task_context_params.o +0 -0
  42. data/ext/cld3/task_spec.pb.o +0 -0
  43. data/ext/cld3/task_spec.proto +0 -98
  44. data/ext/cld3/text_processing.o +0 -0
  45. data/ext/cld3/unicodetext.o +0 -0
  46. data/ext/cld3/utf8statetable.o +0 -0
  47. data/ext/cld3/utils.o +0 -0
  48. data/ext/cld3/workspace.o +0 -0
  49. data/lib/a.rb +0 -24
  50. data/lib/cld3/unstable.rb +0 -58
@@ -1,50 +0,0 @@
1
- /* Copyright 2016 Google Inc. All Rights Reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
14
- ==============================================================================*/
15
-
16
- // Protocol buffers for feature extractor.
17
-
18
- syntax = "proto2";
19
- option optimize_for = LITE_RUNTIME;
20
-
21
- package chrome_lang_id;
22
-
23
- message Parameter {
24
- optional string name = 1;
25
- optional string value = 2;
26
- }
27
-
28
- // Descriptor for feature function.
29
- message FeatureFunctionDescriptor {
30
- // Feature function type.
31
- required string type = 1;
32
-
33
- // Feature function name.
34
- optional string name = 2;
35
-
36
- // Default argument for feature function.
37
- optional int32 argument = 3 [default = 0];
38
-
39
- // Named parameters for feature descriptor.
40
- repeated Parameter parameter = 4;
41
-
42
- // Nested sub-feature function descriptors.
43
- repeated FeatureFunctionDescriptor feature = 7;
44
- };
45
-
46
- // Descriptor for feature extractor.
47
- message FeatureExtractorDescriptor {
48
- // Top-level feature function for extractor.
49
- repeated FeatureFunctionDescriptor feature = 1;
50
- };
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/ext/cld3/libcld3.def DELETED
@@ -1,8 +0,0 @@
1
- EXPORTS
2
- NNetLanguageIdentifier_find_language
3
- NNetLanguageIdentifier_find_top_n_most_freq_langs
4
- delete_NNetLanguageIdentifier
5
- delete_result
6
- delete_results
7
- new_NNetLanguageIdentifier
8
- refer_to_nth_result
data/ext/cld3/libcld3.so DELETED
Binary file
data/ext/cld3/mkmf.log DELETED
@@ -1,37 +0,0 @@
1
- "pkg-config --exists protobuf"
2
- | pkg-config --libs protobuf
3
- => "-lprotobuf -lpthread \n"
4
- "gcc -o conftest -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fPIC conftest.c -L. -L/usr/lib64 -L. -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -rdynamic -Wl,-export-dynamic -lruby -lm -lc"
5
- checked program was:
6
- /* begin */
7
- 1: #include "ruby.h"
8
- 2:
9
- 3: int main(int argc, char **argv)
10
- 4: {
11
- 5: return !!argv[argc];
12
- 6: }
13
- /* end */
14
-
15
- "gcc -o conftest -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fPIC conftest.c -L. -L/usr/lib64 -L. -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -rdynamic -Wl,-export-dynamic -lruby -lprotobuf -lpthread -lm -lc"
16
- checked program was:
17
- /* begin */
18
- 1: #include "ruby.h"
19
- 2:
20
- 3: int main(int argc, char **argv)
21
- 4: {
22
- 5: return !!argv[argc];
23
- 6: }
24
- /* end */
25
-
26
- | pkg-config --cflags-only-I protobuf
27
- => "\n"
28
- | pkg-config --cflags-only-other protobuf
29
- => "\n"
30
- | pkg-config --libs-only-l protobuf
31
- => "-lprotobuf -lpthread \n"
32
- package configuration for protobuf
33
- incflags:
34
- cflags:
35
- ldflags:
36
- libs: -lprotobuf -lpthread
37
-
Binary file
Binary file
data/ext/cld3/offsetmap.o DELETED
Binary file
data/ext/cld3/registry.o DELETED
Binary file
Binary file
Binary file
@@ -1,77 +0,0 @@
1
- /* Copyright 2016 Google Inc. All Rights Reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
14
- ==============================================================================*/
15
-
16
- // Protocol buffer specification for sentence analysis.
17
-
18
- syntax = "proto2";
19
- option optimize_for = LITE_RUNTIME;
20
-
21
- package chrome_lang_id;
22
-
23
- // A Sentence contains the raw text contents of a sentence, as well as an
24
- // analysis.
25
- message Sentence {
26
- // Identifier for sentence.
27
- optional string id = 1;
28
-
29
- // Raw text contents of the sentence.
30
- optional string text = 2;
31
-
32
- // Tokenization of the sentence.
33
- repeated Token token = 3;
34
-
35
- extensions 1000 to max;
36
- }
37
-
38
- // A sentence token marks a span of bytes in the sentence text as a token
39
- // or word.
40
- message Token {
41
- // Token word form.
42
- required string word = 1;
43
-
44
- // Start position of token in text.
45
- required int32 start = 2;
46
-
47
- // End position of token in text. Gives index of last byte, not one past
48
- // the last byte. If token came from lexer, excludes any trailing HTML tags.
49
- required int32 end = 3;
50
-
51
- // Head of this token in the dependency tree: the id of the token which has an
52
- // arc going to this one. If it is the root token of a sentence, then it is
53
- // set to -1.
54
- optional int32 head = 4 [default = -1];
55
-
56
- // Part-of-speech tag for token.
57
- optional string tag = 5;
58
-
59
- // Coarse-grained word category for token.
60
- optional string category = 6;
61
-
62
- // Label for dependency relation between this token and its head.
63
- optional string label = 7;
64
-
65
- // Break level for tokens that indicates how it was separated from the
66
- // previous token in the text.
67
- enum BreakLevel {
68
- NO_BREAK = 0; // No separation between tokens.
69
- SPACE_BREAK = 1; // Tokens separated by space.
70
- LINE_BREAK = 2; // Tokens separated by line break.
71
- SENTENCE_BREAK = 3; // Tokens separated by sentence break.
72
- }
73
-
74
- optional BreakLevel break_level = 8 [default = SPACE_BREAK];
75
-
76
- extensions 1000 to max;
77
- }
Binary file
Binary file
Binary file
Binary file
@@ -1,98 +0,0 @@
1
- /* Copyright 2016 Google Inc. All Rights Reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
14
- ==============================================================================*/
15
-
16
- // LINT: ALLOW_GROUPS
17
- // Protocol buffer specifications for task configuration.
18
-
19
- syntax = "proto2";
20
- option optimize_for = LITE_RUNTIME;
21
-
22
- package chrome_lang_id;
23
-
24
- // Task input descriptor.
25
- message TaskInput {
26
- // Name of input resource.
27
- required string name = 1;
28
-
29
- // Name of stage responsible of creating this resource.
30
- optional string creator = 2;
31
-
32
- // File format for resource.
33
- repeated string file_format = 3;
34
-
35
- // Record format for resource.
36
- repeated string record_format = 4;
37
-
38
- // Is this resource multi-file?
39
- optional bool multi_file = 5 [default = false];
40
-
41
- // An input can consist of multiple file sets.
42
- repeated group Part = 6 {
43
- // File pattern for file set.
44
- optional string file_pattern = 7;
45
-
46
- // File format for file set.
47
- optional string file_format = 8;
48
-
49
- // Record format for file set.
50
- optional string record_format = 9;
51
- }
52
- }
53
-
54
- // Task output descriptor.
55
- message TaskOutput {
56
- // Name of output resource.
57
- required string name = 1;
58
-
59
- // File format for output resource.
60
- optional string file_format = 2;
61
-
62
- // Record format for output resource.
63
- optional string record_format = 3;
64
-
65
- // Number of shards in output. If it is different from zero this output is
66
- // sharded. If the number of shards is set to -1 this means that the output is
67
- // sharded, but the number of shard is unknown. The files are then named
68
- // 'base-*-of-*'.
69
- optional int32 shards = 4 [default = 0];
70
-
71
- // Base file name for output resource. If this is not set by the task
72
- // component it is set to a default value by the workflow engine.
73
- optional string file_base = 5;
74
-
75
- // Optional extension added to the file name.
76
- optional string file_extension = 6;
77
- }
78
-
79
- // A task specification is used for describing executing parameters.
80
- message TaskSpec {
81
- // Name of task.
82
- optional string task_name = 1;
83
-
84
- // Workflow task type.
85
- optional string task_type = 2;
86
-
87
- // Task parameters.
88
- repeated group Parameter = 3 {
89
- required string name = 4;
90
- optional string value = 5;
91
- }
92
-
93
- // Task inputs.
94
- repeated TaskInput input = 6;
95
-
96
- // Task outputs.
97
- repeated TaskOutput output = 7;
98
- }
Binary file
Binary file
Binary file
data/ext/cld3/utils.o DELETED
Binary file
data/ext/cld3/workspace.o DELETED
Binary file
data/lib/a.rb DELETED
@@ -1,24 +0,0 @@
1
- require "cld3"
2
-
3
- # Kafka text as an example + the word Velcro
4
- text = "Πολυαγαπημένε πατέρα πρόσφατα Velcro με ρώτησες κάποια φορά γιατί ισχυρίζομαι πως σε φοβάμαι. Εγώ δεν ήξερα, ως συνήθως, τι να σου απαντήσω, εν μέρει ακριβώς λόγω του φόβου που νιώθω για σένα, εν μέρει επειδή στην αιτιολόγηση του φόβου αυτού συγκαταλέγονται πάρα πολλές λεπτομέρειες, που εν τη ρύμη του λόγου εγώ ούτε κατά το ήμισυ δεν θα μπορούσα να τις συγκρατήσω. Κι αν εδώ προσπαθώ να σου απαντήσω γραπτώς, μόνο ανολοκλήρωτο κατά πολύ θα αποβεί και τούτο, επειδή και κατά τη γραφή ο φόβος και οι συνέπειές του με κωλύουν έναντί σου κι επειδή το μέγεθος του υλικού εν γένει υπερβαίνει κατά πολύ τη μνήμη μου και το λογικό μου. Για σένα το ζήτημα αποδεικνυόταν πάντοτε πολύ απλό, τουλάχιστον στον βαθμό που μιλούσες εσύ γι’ αυτό ενώπιόν μου και, αδιακρίτως, ενώπιον πολλών άλλων. Εσένα σου φαινόταν να είναι κάπως έτσι: Εσύ εργαζόσουν σκληρά σ’ όλη σου τη ζωή, τα πάντα για τα παιδιά σου, προ πάντων για εμένα τα θυσίαζες, εγώ έκαμνα συνεπώς «ζωή χαρισάμενη», είχα πλήρη ελευθερία να μάθω ό,τι ήθελα, κανέναν λόγο δεν είχα να έχω έγνοιες για την καθημερινή διατροφή, να έχω έγνοιες συνεπώς εν γένει• εσύ αντ’ αυτών καμμίαν ευγνωμοσύνη δεν αξίωνες, γνωρίζεις «την ευγνωμοσύνη των παιδιών, αλλά εν τούτοις τουλάχιστον μια "
5
- pp text.bytesize
6
-
7
- 200.times { |i|
8
- max_bytes = 500 + i * 10
9
- cld3 = CLD3::NNetLanguageIdentifier.new("foo", max_bytes)
10
-
11
- lang = cld3.find_language(text)
12
- lang2 = cld3.find_top_n_most_freq_langs(text, 1)
13
-
14
- puts "When max_bytes is #{max_bytes} probability is less than 0.999: #{lang.probability}" if lang.probability < 0.999
15
-
16
- if lang.language != :el
17
- puts "When max_bytes is #{max_bytes} then cld3::find_language returns #{lang.language},
18
- find_top_n_most_freq_langs returns #{lang2.first.language}"
19
- #pp lang
20
- #pp lang2
21
- end
22
- }
23
-
24
- puts "Size: #{text.length} - Bytesize: #{text.encode(Encoding::UTF_8).bytesize}"
data/lib/cld3/unstable.rb DELETED
@@ -1,58 +0,0 @@
1
-
2
- # Copyright 2021 Akihiko Odaki <akihiko.odaki@gmail.com>
3
- # All Rights Reserved.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- # ==============================================================================
17
-
18
- module CLD3
19
- module Unstable
20
- extend FFI::Library
21
-
22
- ffi_lib File.join(__dir__, "..", "..", "ext", "cld3", "libcld3." + RbConfig::CONFIG["DLEXT"])
23
-
24
- module NNetLanguageIdentifier
25
- class Pointer < FFI::AutoPointer
26
- def self.release(pointer)
27
- Unstable.delete_NNetLanguageIdentifier(pointer)
28
- end
29
- end
30
-
31
- class SpanInfo < FFI::Struct
32
- layout :start_index, :int, :end_index, :int, :probability, :float
33
- end
34
-
35
- class Result < FFI::Struct
36
- layout :language_data, :pointer, :language_size, :size_t, :byte_ranges_data, :pointer, :byte_ranges_size, :size_t, :probability, :float, :proportion, :float, :reliable?, :bool
37
- end
38
- end
39
-
40
- attach_function :delete_NNetLanguageIdentifier, [ :pointer ], :void
41
-
42
- attach_function :delete_result, [ :pointer ], :void
43
-
44
- attach_function :delete_results, [ :pointer ], :void
45
-
46
- attach_function :new_NNetLanguageIdentifier, [ :int, :int ], :pointer
47
-
48
- attach_function :refer_to_nth_result, [ :pointer, :size_t ], NNetLanguageIdentifier::Result.by_value
49
-
50
- attach_function :NNetLanguageIdentifier_find_language,
51
- [ :pointer, :buffer_in, :size_t ], :pointer
52
-
53
- attach_function :NNetLanguageIdentifier_find_top_n_most_freq_langs,
54
- [ :pointer, :buffer_in, :size_t, :int ], :pointer
55
- end
56
-
57
- private_constant :Unstable
58
- end