Skip to content

Instantly share code, notes, and snippets.

Created Mar 6, 2018
What would you like to do?
def get_entity(decorated)
start_index, entity, end_index = { |y|
Plugin.filtering(:entity_filter, decorated, y)
return [decorated] if !start_index
target_text = decorated.description
parent: decorated,
description: target_text[0...start_index]),
parent: decorated,
description: target_text[end_index..target_text.size])
).each{|e| e.parent = decorated }
get_entity({ field.string :description }.new(description: "I'm at 珈琲 庵 in 千代田区, 東京都 w/ @toshi_a @akkiesoft")).map(&:description)
["text entity(I'm at 珈琲 庵 in 千代田区, 東京都 w/ )",
"hyperlink entity(@toshi_a, href=",
"text entity( )",
"hyperlink entity(@akkiesoft, href=",
"text entity( )",
"hyperlink entity(, href=",
"text entity()"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment