ispras-api 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/ispras-api.gemspec +3 -3
- data/lib/ispras-api/texterra/nlp.rb +21 -8
- data/lib/ispras-api/texterra/nlp_specs.rb +14 -7
- data/lib/ispras-api/texterra_api.rb +1 -1
- data/lib/ispras-api/version.rb +3 -3
- data/test/test_texterra_api.rb +4 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d2d97d731d049fad8633aeea5973e528ad4789f
|
4
|
+
data.tar.gz: 9bc5749c1ce6be7acb93c94e5da8665f82d1b1d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acc400f54c5d5337a9d4fd28df7c1462a81805758fac8cdd045f273bd5ebf50a3138b37c946c376d5d5ceba50d0cc890454661d66cea2e18a9ce0a14504ed6e1
|
7
|
+
data.tar.gz: 7a1796425af31990a812860849b092186ac26d3f4fde130d0b0eec44c78c9fc97034fd105fd8bd261951dfb1eb424d0580afa855aa87c96276b9be2d46cb0701
|
data/ispras-api.gemspec
CHANGED
@@ -7,10 +7,10 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.files = `git ls-files`.split($\)
|
8
8
|
s.require_paths = ['lib']
|
9
9
|
s.add_runtime_dependency 'httparty', '~> 0.13'
|
10
|
-
s.add_runtime_dependency 'nori', '~> 2.
|
10
|
+
s.add_runtime_dependency 'nori', '~> 2.6'
|
11
11
|
s.add_development_dependency 'rake', '~> 10.4'
|
12
|
-
s.add_development_dependency 'minitest', '~> 5.
|
13
|
-
s.add_development_dependency 'dotenv', '~>
|
12
|
+
s.add_development_dependency 'minitest', '~> 5.6'
|
13
|
+
s.add_development_dependency 'dotenv', '~> 2.0'
|
14
14
|
s.summary = 'ISPRAS API Ruby SDK'
|
15
15
|
s.description = 'This is Ruby wrapper for REST API provided by ISPRAS. More info at https://api.ispras.ru/'
|
16
16
|
s.homepage = 'https://github.com/alexlag/ispapi.ruby'
|
@@ -122,10 +122,7 @@ module TexterraNLP
|
|
122
122
|
result = POST(specs[:path] % domain, specs[:params], text: text)[:nlp_document][:annotations][:i_annotation]
|
123
123
|
return [] if result.nil?
|
124
124
|
result = [].push result unless result.is_a? Array
|
125
|
-
result.
|
126
|
-
st, en = e[:start].to_i, e[:end].to_i
|
127
|
-
e[:text] = e[:annotated_text] = text[st..en]
|
128
|
-
end
|
125
|
+
result.map { |e| assign_text(e, text) }
|
129
126
|
end
|
130
127
|
|
131
128
|
# Detects Twitter-specific entities: Hashtags, User names, Emoticons, URLs.
|
@@ -137,6 +134,16 @@ module TexterraNLP
|
|
137
134
|
preset_nlp(:tweetNormalization, text)
|
138
135
|
end
|
139
136
|
|
137
|
+
# Detects Syntax relations in text. Only works for russian texts
|
138
|
+
#
|
139
|
+
# @param [String] text Text to process
|
140
|
+
# @return [Array] Texterra annotations
|
141
|
+
def syntax_detection(text)
|
142
|
+
preset_nlp(:syntaxDetection, text).each do |an|
|
143
|
+
an[:value][:parent_token] = assign_text(an[:value][:parent_token], text) if an[:value] && an[:value][:parent_token]
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
140
147
|
private
|
141
148
|
|
142
149
|
# Utility NLP part method
|
@@ -145,9 +152,15 @@ module TexterraNLP
|
|
145
152
|
result = POST(specs[:path], specs[:params], text: text)[:nlp_document][:annotations][:i_annotation]
|
146
153
|
return [] if result.nil?
|
147
154
|
result = [].push result unless result.is_a? Array
|
148
|
-
result.
|
149
|
-
|
150
|
-
|
151
|
-
|
155
|
+
result.map { |an| assign_text(an, text) }
|
156
|
+
end
|
157
|
+
|
158
|
+
# Utility text assignement for annotation
|
159
|
+
def assign_text(an, text)
|
160
|
+
return an unless an && an[:start] && an[:end]
|
161
|
+
st, en = an[:start].to_i, an[:end].to_i
|
162
|
+
an[:text] = text[st..en]
|
163
|
+
an[:annotated_text] = text
|
164
|
+
an
|
152
165
|
end
|
153
166
|
end
|
@@ -2,7 +2,7 @@ module TexterraNLPSpecs
|
|
2
2
|
# Path and parameters for preset NLP queries
|
3
3
|
NLP_SPECS = {
|
4
4
|
languageDetection: {
|
5
|
-
path: 'nlp/
|
5
|
+
path: 'nlp/language',
|
6
6
|
params: {
|
7
7
|
class: 'ru.ispras.texterra.core.nlp.datamodel.Language',
|
8
8
|
filtering: 'KEEPING'
|
@@ -37,28 +37,28 @@ module TexterraNLPSpecs
|
|
37
37
|
}
|
38
38
|
},
|
39
39
|
spellingCorrection: {
|
40
|
-
path: 'nlp/
|
40
|
+
path: 'nlp/spellingcorrection',
|
41
41
|
params: {
|
42
42
|
class: 'ru.ispras.texterra.core.nlp.datamodel.SpellingCorrection',
|
43
43
|
filtering: 'KEEPING'
|
44
44
|
}
|
45
45
|
},
|
46
46
|
namedEntities: {
|
47
|
-
path: 'nlp/
|
47
|
+
path: 'nlp/namedentity',
|
48
48
|
params: {
|
49
49
|
class: 'ru.ispras.texterra.core.nlp.datamodel.ne.NamedEntityToken',
|
50
50
|
filtering: 'KEEPING'
|
51
51
|
}
|
52
52
|
},
|
53
53
|
termDetection: {
|
54
|
-
path: 'nlp/
|
54
|
+
path: 'nlp/term',
|
55
55
|
params: {
|
56
56
|
class: 'ru.ispras.texterra.core.nlp.datamodel.Frame',
|
57
57
|
filtering: 'KEEPING'
|
58
58
|
}
|
59
59
|
},
|
60
60
|
disambiguation: {
|
61
|
-
path: 'nlp/
|
61
|
+
path: 'nlp/disambiguation',
|
62
62
|
params: {
|
63
63
|
class: 'ru.ispras.texterra.core.nlp.datamodel.DisambiguatedPhrase',
|
64
64
|
filtering: 'KEEPING'
|
@@ -66,7 +66,7 @@ module TexterraNLPSpecs
|
|
66
66
|
|
67
67
|
},
|
68
68
|
keyConcepts: {
|
69
|
-
path: 'nlp/
|
69
|
+
path: 'nlp/keyconcepts',
|
70
70
|
params: {
|
71
71
|
class: 'ru.ispras.texterra.core.nlp.datamodel.KeyconceptsSemanticContext',
|
72
72
|
filtering: 'KEEPING'
|
@@ -119,7 +119,14 @@ module TexterraNLPSpecs
|
|
119
119
|
class: %w(sentence language token),
|
120
120
|
filtering: 'REMOVING'
|
121
121
|
}
|
122
|
-
|
122
|
+
},
|
123
|
+
syntaxDetection: {
|
124
|
+
path: 'nlp/syntax',
|
125
|
+
params: {
|
126
|
+
class: 'ru.ispras.texterra.core.nlp.datamodel.syntax.SyntaxRelation',
|
127
|
+
filtering: 'KEEPING'
|
128
|
+
}
|
123
129
|
}
|
130
|
+
|
124
131
|
}
|
125
132
|
end
|
@@ -31,7 +31,7 @@ class TexterraAPI < IsprasAPI
|
|
31
31
|
key_concepts = key_concepts_annotate(text)[0][:value][:concepts_weights][:entry] || []
|
32
32
|
key_concepts = [].push key_concepts unless key_concepts.is_a? Array
|
33
33
|
key_concepts.map do |kc|
|
34
|
-
kc[:concept][:weight] = kc[:double]
|
34
|
+
kc[:concept][:weight] = kc[:double]
|
35
35
|
kc[:concept]
|
36
36
|
end
|
37
37
|
end
|
data/lib/ispras-api/version.rb
CHANGED
data/test/test_texterra_api.rb
CHANGED
@@ -49,6 +49,10 @@ class TestTexterraAPI < Minitest::Test
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
def test_syntax_detection
|
53
|
+
assert_instance_of Array, @texterra.syntax_detection(@ru_text)
|
54
|
+
end
|
55
|
+
|
52
56
|
def test_language_detection_annotate
|
53
57
|
assert_instance_of Array, @texterra.language_detection_annotate(@en_text)
|
54
58
|
assert_instance_of Array, @texterra.language_detection_annotate(@ru_text)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ispras-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Laguta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '2.
|
33
|
+
version: '2.6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '2.
|
40
|
+
version: '2.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,28 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '5.
|
61
|
+
version: '5.6'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '5.
|
68
|
+
version: '5.6'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: dotenv
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '2.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '2.0'
|
83
83
|
description: This is Ruby wrapper for REST API provided by ISPRAS. More info at https://api.ispras.ru/
|
84
84
|
email: laguta@ispras.ru
|
85
85
|
executables: []
|