Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tiendung committed Aug 11, 2008
0 parents commit c681094
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 0 deletions.
Binary file added left3words-wsj-0-18.tagger
Binary file not shown.
23 changes: 23 additions & 0 deletions measure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Measure
@count = 0
MAX_TASK_NAME_LEN = 30

def self.time( task_name, total = 1, &block )
@count += 1
header = "[ Run task #{task_number = @count} #{total} times ]"

short_name = task_name[0..MAX_TASK_NAME_LEN] + ( task_name.length > MAX_TASK_NAME_LEN ? '...' : '' )

start_time = Time.now

puts "#{header} Start '#{short_name}' at #{start_time.to_s.to_s.match(/\d+:\d+:\d+/)[0]}"

1.upto(total) {
block.call
}

end_time = Time.now

puts "#{header} Spent #{(end_time - start_time).to_i} seconds on '#{short_name}'"
end
end
Binary file added ner-eng-ie.crf-4-conll.ser.gz
Binary file not shown.
19 changes: 19 additions & 0 deletions nlp.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'measure'
require 'rjb'

Rjb::load('stanford-postagger.jar:stanford-ner.jar', ['-Xmx200m'])

CRFClassifier = Rjb::import('edu.stanford.nlp.ie.crf.CRFClassifier')
classifier = CRFClassifier.getClassifierNoExceptions("ner-eng-ie.crf-4-conll.ser.gz")

MaxentTagger = Rjb::import('edu.stanford.nlp.tagger.maxent.MaxentTagger')
MaxentTagger.init("left3words-wsj-0-18.tagger")

Sentence = Rjb::import('edu.stanford.nlp.ling.Sentence')

sent = "Good afternoon Rajat Raina, how are you today?"

Measure.time "NER", 10 do
puts classifier.testString( sent )
puts MaxentTagger.tagString( sent )
end
Binary file added stanford-ner.jar
Binary file not shown.
Binary file added stanford-postagger.jar
Binary file not shown.

0 comments on commit c681094

Please sign in to comment.