abstractor 4.4.2 → 4.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/abstractor/methods/models/abstractor_subject.rb +89 -66
- data/lib/abstractor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e287ee46744b138166b5013a594f17488f48592
|
4
|
+
data.tar.gz: 00931cda0cb5d0d6fc03c263cf26da3fe130c120
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 697b42f689aa4d88915d5431d62f96255bb16bab03166a0a2ae55bbee53f437be36cb8661c97e6f41c45797fb9d3ec52d4f8f762ab495571c43e8130fef948e0
|
7
|
+
data.tar.gz: 297cbf1b6752fec3e279bd22d48abc634f911278ca3738d2dc36e6ba2079fb512aa762a32b7197309d24a66628377cd0e0ea666036d4f2c908023d41fab3ad6e
|
@@ -253,104 +253,127 @@ module Abstractor
|
|
253
253
|
abstractor_text = Abstractor::AbstractorAbstractionSource.abstractor_text(source)
|
254
254
|
parser = Abstractor::Parser.new(abstractor_text)
|
255
255
|
|
256
|
+
sentences = []
|
257
|
+
# get all matching sentences
|
256
258
|
abstractor_abstraction_schema.predicate_variants.each do |predicate_variant|
|
257
259
|
ranges = parser.range_all(Regexp.escape(predicate_variant), word_boundary: false)
|
258
260
|
ranges.each do |range|
|
259
261
|
sentence = parser.find_sentence(range)
|
260
|
-
if sentence
|
261
|
-
is_abstracted = abstract_canonical_name_value(about, abstractor_abstraction, abstractor_abstraction_source, source, parser, sentence, predicate_variant)
|
262
|
-
abstract_sentential_name_value(about, abstractor_abstraction, abstractor_abstraction_source, source, parser, sentence, predicate_variant) unless is_abstracted
|
263
|
-
end
|
262
|
+
sentences << sentence if sentence
|
264
263
|
end
|
265
264
|
end
|
265
|
+
sentences.uniq.each do |sentence|
|
266
|
+
skip_sentinental = abstract_canonical_name_value(about, abstractor_abstraction, abstractor_abstraction_source, source, parser, sentence)
|
267
|
+
abstract_sentential_name_value(about, abstractor_abstraction, abstractor_abstraction_source, source, parser, sentence) unless skip_sentinental
|
268
|
+
end
|
266
269
|
end
|
267
270
|
create_unknown_abstractor_suggestion_name_only(about, abstractor_abstraction, abstractor_abstraction_source)
|
268
271
|
create_unknown_abstractor_suggestion(about, abstractor_abstraction, abstractor_abstraction_source)
|
269
272
|
end
|
270
273
|
|
271
|
-
def abstract_canonical_name_value(about, abstractor_abstraction, abstractor_abstraction_source, source, parser, sentence
|
272
|
-
|
273
|
-
|
274
|
-
|
274
|
+
def abstract_canonical_name_value(about, abstractor_abstraction, abstractor_abstraction_source, source, parser, sentence)
|
275
|
+
skip_sentinental = false
|
276
|
+
abstractor_abstraction_schema.predicate_variants.each do |predicate_variant|
|
277
|
+
if abstractor_abstraction_schema.abstractor_object_type && (abstractor_abstraction_schema.abstractor_object_type.number? || abstractor_abstraction_schema.abstractor_object_type.number_list?)
|
278
|
+
object_regex = Abstractor::Enum::NUMERIC_REGEX
|
275
279
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
280
|
+
match_values = ["#{Regexp.escape(predicate_variant)}:\s*#{object_regex}", "#{Regexp.escape(predicate_variant)}#{object_regex}"]
|
281
|
+
match_values.each do |match_value|
|
282
|
+
matches = parser.sentence_match_scan(sentence[:sentence], match_value, word_boundary: true).uniq
|
283
|
+
if abstractor_abstraction_schema.abstractor_object_type.number_list?
|
284
|
+
# filter matched numbers by list of available values
|
285
|
+
abstractor_abstraction_schema.abstractor_object_values.each do |abstractor_object_value|
|
286
|
+
abstractor_object_value.object_variants.each do |object_variant|
|
287
|
+
matches.each do |match|
|
288
|
+
if object_variant == match[:object_value]
|
289
|
+
skip_sentinental = suggest(abstractor_abstraction, abstractor_abstraction_source, match.to_s, match.to_s, source[:source_id], source[:source_type].to_s, source[:source_method], source[:section_name], abstractor_object_value, nil, nil, nil, nil)
|
290
|
+
end
|
286
291
|
end
|
287
292
|
end
|
288
293
|
end
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
294
|
+
else
|
295
|
+
matches.each do |match|
|
296
|
+
skip_sentinental = suggest(abstractor_abstraction, abstractor_abstraction_source, match.to_s, match.to_s, source[:source_id], source[:source_type].to_s, source[:source_method], source[:section_name], match[:object_value], nil, nil, nil, nil)
|
297
|
+
end
|
293
298
|
end
|
294
299
|
end
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
300
|
+
else
|
301
|
+
abstractor_abstraction_schema.abstractor_object_values.each do |abstractor_object_value|
|
302
|
+
abstractor_object_value.object_variants.each do |object_variant|
|
303
|
+
match_values = ["#{Regexp.escape(predicate_variant)}:\s*#{Regexp.escape(object_variant)}", "#{Regexp.escape(predicate_variant)}#{Regexp.escape(object_variant)}"]
|
304
|
+
match_values.each do |match_value|
|
305
|
+
matches = parser.sentence_scan(sentence[:sentence], match_value, word_boundary: true).uniq
|
306
|
+
matches.each do |match|
|
307
|
+
suggest(abstractor_abstraction, abstractor_abstraction_source, match, match, source[:source_id], source[:source_type].to_s, source[:source_method], source[:section_name], abstractor_object_value, nil, nil, nil, nil)
|
308
|
+
end
|
304
309
|
end
|
305
310
|
end
|
306
311
|
end
|
307
312
|
end
|
308
313
|
end
|
309
|
-
|
314
|
+
skip_sentinental
|
310
315
|
end
|
311
316
|
|
312
|
-
def abstract_sentential_name_value(about, abstractor_abstraction, abstractor_abstraction_source, source, parser, sentence
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
abstractor_abstraction_schema.abstractor_object_values.each do |abstractor_object_value|
|
329
|
-
abstractor_object_value.object_variants.each do |object_variant|
|
330
|
-
if object_variant == match[:object_value]
|
331
|
-
suggest(abstractor_abstraction, abstractor_abstraction_source, sentence[:sentence], sentence[:sentence], source[:source_id], source[:source_type].to_s, source[:source_method], source[:section_name], abstractor_object_value, nil, nil, nil, nil)
|
332
|
-
end
|
317
|
+
def abstract_sentential_name_value(about, abstractor_abstraction, abstractor_abstraction_source, source, parser, sentence)
|
318
|
+
abstractor_abstraction_schema.predicate_variants.each do |predicate_variant|
|
319
|
+
if match = parser.match_sentence(sentence[:sentence], predicate_variant)
|
320
|
+
if abstractor_abstraction_schema.abstractor_object_type && (abstractor_abstraction_schema.abstractor_object_type.number? || abstractor_abstraction_schema.abstractor_object_type.number_list?)
|
321
|
+
object_regex = object_regex = Abstractor::Enum::NUMERIC_REGEX
|
322
|
+
filtered_matches = parser.sentence_match_scan(sentence[:sentence], object_regex).reject{|m| m.begin(0) > match.begin(0) && m.end(0) < match.end(0)}
|
323
|
+
if filtered_matches.any?
|
324
|
+
closest_post_match = filtered_matches.select{|m| m.begin(0) > match.end(0)}.first
|
325
|
+
closest_pre_match = filtered_matches.select{|m| m.end(0) < match.begin(0)}.last
|
326
|
+
|
327
|
+
closest_match = nil
|
328
|
+
if closest_post_match && closest_pre_match
|
329
|
+
if closest_post_match.begin(0) - match.end(0) > match.begin(0) - closest_pre_match.end(0) and sentence[:sentence][closest_pre_match.end(0)..match.begin(0)] !~ /[,;]/
|
330
|
+
closest_match = closest_pre_match
|
331
|
+
else
|
332
|
+
closest_match = closest_post_match
|
333
333
|
end
|
334
|
+
else
|
335
|
+
closest_match = closest_post_match
|
336
|
+
closest_match ||= closest_pre_match
|
334
337
|
end
|
335
|
-
|
336
|
-
is_abstracted = suggest(abstractor_abstraction, abstractor_abstraction_source, sentence[:sentence], sentence[:sentence], source[:source_id], source[:source_type].to_s, source[:source_method], source[:section_name], match[:object_value], nil, nil, nil, nil)
|
337
|
-
end
|
338
|
-
end
|
339
|
-
end
|
340
|
-
else
|
341
|
-
abstractor_abstraction_schema.abstractor_object_values.each do |abstractor_object_value|
|
342
|
-
abstractor_object_value.object_variants.each do |object_variant|
|
343
|
-
match = parser.match_sentence(sentence[:sentence], Regexp.escape(object_variant))
|
344
|
-
if match
|
338
|
+
|
345
339
|
scoped_sentence = Abstractor::NegationDetection.parse_negation_scope(sentence[:sentence])
|
346
340
|
reject = (
|
347
341
|
Abstractor::NegationDetection.negated_match_value?(scoped_sentence[:scoped_sentence], predicate_variant) ||
|
348
342
|
Abstractor::NegationDetection.manual_negated_match_value?(sentence[:sentence], predicate_variant) ||
|
349
|
-
Abstractor::NegationDetection.negated_match_value?(scoped_sentence[:scoped_sentence],
|
350
|
-
Abstractor::NegationDetection.manual_negated_match_value?(sentence[:sentence],
|
343
|
+
Abstractor::NegationDetection.negated_match_value?(scoped_sentence[:scoped_sentence], closest_match[:object_value]) ||
|
344
|
+
Abstractor::NegationDetection.manual_negated_match_value?(sentence[:sentence], closest_match[:object_value])
|
351
345
|
)
|
352
346
|
if !reject
|
353
|
-
|
347
|
+
if abstractor_abstraction_schema.abstractor_object_type.number_list?
|
348
|
+
# filter matched numbers by list of available values
|
349
|
+
abstractor_abstraction_schema.abstractor_object_values.each do |abstractor_object_value|
|
350
|
+
abstractor_object_value.object_variants.each do |object_variant|
|
351
|
+
if object_variant == closest_match[:object_value]
|
352
|
+
suggest(abstractor_abstraction, abstractor_abstraction_source, sentence[:sentence], sentence[:sentence], source[:source_id], source[:source_type].to_s, source[:source_method], source[:section_name], abstractor_object_value, nil, nil, nil, nil)
|
353
|
+
end
|
354
|
+
end
|
355
|
+
end
|
356
|
+
else
|
357
|
+
suggest(abstractor_abstraction, abstractor_abstraction_source, sentence[:sentence], sentence[:sentence], source[:source_id], source[:source_type].to_s, source[:source_method], source[:section_name], closest_match[:object_value], nil, nil, nil, nil)
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
else
|
362
|
+
abstractor_abstraction_schema.abstractor_object_values.each do |abstractor_object_value|
|
363
|
+
abstractor_object_value.object_variants.each do |object_variant|
|
364
|
+
match = parser.match_sentence(sentence[:sentence], Regexp.escape(object_variant))
|
365
|
+
if match
|
366
|
+
scoped_sentence = Abstractor::NegationDetection.parse_negation_scope(sentence[:sentence])
|
367
|
+
reject = (
|
368
|
+
Abstractor::NegationDetection.negated_match_value?(scoped_sentence[:scoped_sentence], predicate_variant) ||
|
369
|
+
Abstractor::NegationDetection.manual_negated_match_value?(sentence[:sentence], predicate_variant) ||
|
370
|
+
Abstractor::NegationDetection.negated_match_value?(scoped_sentence[:scoped_sentence], object_variant) ||
|
371
|
+
Abstractor::NegationDetection.manual_negated_match_value?(sentence[:sentence], object_variant)
|
372
|
+
)
|
373
|
+
if !reject
|
374
|
+
suggest(abstractor_abstraction, abstractor_abstraction_source, sentence[:sentence], sentence[:sentence], source[:source_id], source[:source_type].to_s, source[:source_method], source[:section_name], abstractor_object_value, nil, nil, nil, nil)
|
375
|
+
end
|
376
|
+
end
|
354
377
|
end
|
355
378
|
end
|
356
379
|
end
|
data/lib/abstractor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abstractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.4.
|
4
|
+
version: 4.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Gurley, Yulia Bushmanova
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|