File: sample_unicode.rb

package info (click to toggle)
simstring 1.0-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,380 kB
  • sloc: cpp: 15,653; sh: 3,846; ansic: 488; python: 205; makefile: 50; ruby: 22
file content (21 lines) | stat: -rw-r--r-- 507 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env ruby -Ku

require 'simstring'

# Open a SimString database for writing with Unicode mode.
db = Simstring::Writer.new('sample_unicode.db', 3, false, true)

# Write a string, and close the database.
db.insert('スパゲティ')
db.close()


# Open the database for reading.
db = Simstring::Reader.new('sample_unicode.db')

# Set a similarity measure and threshold.
db.measure = Simstring::Cosine
db.threshold = 0.6

# Use an 8-bit string in UTF-8 encoding.
p(db.retrieve('スパゲティー'))