-
-
Save kelciour/d281f2091c63ef39698896b2f549413b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
require 'pragmatic_segmenter' | |
directory_name = "output" | |
Dir.mkdir(directory_name) unless File.exists?(directory_name) | |
Dir.glob('*.txt') do |txt_file| | |
puts txt_file | |
text = File.open(txt_file, "r:UTF-8", &:read) | |
ps = PragmaticSegmenter::Segmenter.new(text: text, language: 'en', clean: false) | |
File.open(directory_name + '/' + txt_file, 'w') { |f| f.puts(ps.segment) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment