aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v2/db_sqltxt.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2010-04-20 19:01:55 -0400
committerRalph Amissah <ralph@amissah.com>2010-04-20 19:01:55 -0400
commit63c5a3cead1fb5cbd9b1bff653f269dce8d8052c (patch)
treeeb3e09a1199ae2dc79b3f7db97ff1024b25cfb0c /lib/sisu/v2/db_sqltxt.rb
parentdal, minor cosmetic re-arrangement (diff)
db name, tables, columns, indexes changes, review (need another version bump 2.2.0)
* db (sql) table structure, further review and changes (hence breakage & version bump) * new pgsql db name prefix "sisu_v2b_" * new table column words in doc_objects & endnotes, VARCHAR 3000 to contain list of unique sorted words in object * increase use of VARCHAR * constants takes on related additions * param, extensive db column size checks for metadata
Diffstat (limited to 'lib/sisu/v2/db_sqltxt.rb')
-rw-r--r--lib/sisu/v2/db_sqltxt.rb34
1 files changed, 20 insertions, 14 deletions
diff --git a/lib/sisu/v2/db_sqltxt.rb b/lib/sisu/v2/db_sqltxt.rb
index 68e9ef8a..17a92683 100644
--- a/lib/sisu/v2/db_sqltxt.rb
+++ b/lib/sisu/v2/db_sqltxt.rb
@@ -72,9 +72,10 @@ module SiSU_DB_text
end
def clean_searchable_text(arr) #produce clean, searchable, plaintext from document source
txt_arr,en=[],[]
+ arr=arr.class==String ? arr.split(/\n+/m) : arr
arr.each do |s|
- s.gsub!(/([*\/_-])\{(.+?)\}\1/,'\2')
- s.gsub!(/^(?:group|poem|code)\{/,''); s.gsub!(/^\}(?:group|poem|code)/,'')
+ s.gsub!(/([*\/_-])\{(.+?)\}\1/m,'\2')
+ s.gsub!(/^(?:group|poem|code)\{/m,''); s.gsub!(/^\}(?:group|poem|code)/m,'')
s.gsub!(/\A(?:@\S+:\s+.+)\Z/m,'')
if s =~/^:A~/
if defined? @md.creator \
@@ -82,26 +83,26 @@ module SiSU_DB_text
and not @md.creator.author.empty?
s.gsub!(/@author/,@md.creator.author)
else
- tell=SiSU_Screen::Ansi.new('v','WARNING Document Author information missing; provide @creator: :author:')
- tell.warn
+ tell=SiSU_Screen::Ansi.new('v','WARNING Document Author information missing; provide @creator: :author:',@md.fnb)
+ tell.warn unless @md.cmd.inspect =~/q/
end
if defined? @md.title \
and defined? @md.title.full \
and not @md.title.full.empty?
s.gsub!(/@title/,@md.title.full)
else
- tell=SiSU_Screen::Ansi.new('v','WARNING Document Title missing; provide @title:')
- tell.warn
+ tell=SiSU_Screen::Ansi.new('v','WARNING Document Title missing; provide @title:',@md.fnb)
+ tell.warn unless @md.cmd.inspect =~/q/
end
end
- s.gsub!(/^(?:_[1-9]\*?|_\*)\s+/,'')
- s.gsub!(/^(?:[1-9]\~(\S+)?)\s+/,'')
- s.gsub!(/^(?::?[A-C]\~(\S+)?)\s+/,'')
- s.gsub!(/^%{1,3} .+/,'') #removed even if contained in code block
- s.gsub!(/<br>/,' ')
- en << s.scan(/~\{\s*(.+?)\s*\}~/)
- s.gsub!(/~\{.+?\}~/,'')
- s.gsub!(/ \s+/,' ')
+ s.gsub!(/^(?:_[1-9]\*?|_\*)\s+/m,'')
+ s.gsub!(/^(?:[1-9]\~(\S+)?)\s+/m,'')
+ s.gsub!(/^(?::?[A-C]\~(\S+)?)\s+/m,'')
+ s.gsub!(/^%{1,3} .+/m,'') #removed even if contained in code block
+ s.gsub!(/<br>/m,' ')
+ en << s.scan(/~\{\s*(.+?)\s*\}~/m)
+ s.gsub!(/~\{.+?\}~/m,'')
+ s.gsub!(/ \s+/m,' ')
#special_character_escape(s)
s
end
@@ -124,6 +125,11 @@ module SiSU_DB_text
str.strip!
str
end
+ def unique_words(str)
+ a=str.scan(/[a-zA-Z0-9\\\/_-]{2,}/) #a=str.scan(/\S+{2,}/)
+ str=a.uniq.sort.join(' ')
+ str
+ end
end
end
__END__