Code Monkey home page Code Monkey logo

summarize's Introduction

Summarize - A Ruby C wrapper for Open Text Summarizer

Installation

Easy

gem install summarize

Manual

git clone https://github.com/ssoper/summarize.git
cd summarize
rake build
gem build summarize.gemspec
gem install summarize-1.0.4.gem

Usage

The summarize method is added to File which you can use to summarize the contents of any plain text file

File.open('path/to/file').summarize

Or use the String method

"text to summarize".summarize

By default it uses an English dictionary for summarizing but forty languages are supported. Pass in the valid ISO 639 language code to use one. A ratio (default is 25%) can also be passed in.

# Parse an article using Portuguese stemming rules with a ratio of 50%
"texto para sumariar".summarize(:language => 'pt', :ratio => 50)

You can also use custom stemming rules

"text to summarize".summarize(:dictionary => 'path/to/custom/dictionary')

Topics can also be returned

# Returns an array with content first and topics second
content, topics = "text to summarize".summarize(:topics => true)
# content => summarized text
# topics  => Comma-delimited string of topics

Dependencies

You must have glib-2.0 and libxml-2.0 installed and properly configured.

Author

Gem written by Sean Soper (@ssoper)

The Open Text Summarizer library was written by Nadav Rotem and can be found at http://libots.sourceforge.net/

Gem fixed to handle UTF-8 encoding by Yury Batenko (@svenyurgensson)

License

Copyright (C) 2010 Sean Soper [email protected]

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

summarize's People

Contributors

ssoper avatar svenyurgensson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

summarize's Issues

Odd behavior when loading custom dict file

Sean:
First, thanks for your work on this. It's a lifesaver. But of course no good deed goes unpunished.

I'm having trouble opening a custom dictionary file. The context is maybe unusual -- I'm in the middle of a block that opens a persistent httpd connection, like this (highly simplified):
httpcon = Net::HTTP.new(server_uri.host, server_uri.port)

fetch many files and summarize them

httpcon.start do |http|

...
## fetch a file
contents, topics = filecontents.summarize( :topics => true, :dictionary => '/some/random/dicfile')
...
end

I get something in the depths of http.rb complaining that it can't open the file, apparently thinking that it should be doing so over the http connection rather than reading it off local disk.

Any ideas? For now, I'm mangling the local (gem) copy of en.xml, but that's not good ;).

t

Weird Error Trying to install Summarize

2 warnings generated.
compiling dictionary.c
dictionary.c:28:10: fatal error: 'libxml/xmlmemory.h' file not found
#include <libxml/xmlmemory.h>
         ^~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [dictionary.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/djdavis/.rvm/gems/ruby-2.6.3/gems/summarize-1.0.3 for inspection.
Results logged to /Users/djdavis/.rvm/gems/ruby-2.6.3/extensions/x86_64-darwin-18/2.6.0/summarize-1.0.3/gem_make.out```

Problem with heroku

Hi,
I am facing in issue when trying to deploy my app to heroku with the summarize gem.
Heroku returns the following error
remote: Fetching dependency metadata from https://rubygems.org
remote: Could not find summarize-1.0.4 in any of the sources.

when I try specifying the github repository in my gemfile before pushing it, I get:
remote: Fetching https://github.com/ssoper/summarize.git
remote: There was a LoadError while loading summarize.gemspec:
remote: cannot load such file -- summarize/summarize from
remote: /tmp/build_4223d0ae60599e1f77e9caca2476e8b3/vendor/bundle/ruby/2.2.0/bundler/gems/summarize-a80c110fa4fe/summarize.gemspec:2:in
remote: `

'
remote:
remote: Does it try to require a relative path? That's been removed in Ruby 1.9.

Please can somebody help me out?
Thank you.

EDIT:
Turns out I was making a mistake in specifying the verison on Heroku. I was referring to version 1.0.4 which is not out on rubygems (it refers to v1.0.3)

undefined method 'summarize'

Hello,

After installing the gem and trying to run a test through irb like:

"My string".summarize(:ratio => 25)

I always get the following error:

NoMethodError: undefined method `summarize' for "your_string":String

It looks like although the gem is installed it is not being recognized. I doubled check I have glib2 and libxml2 installed.

Any idea on how to solve this?
Thanks!

Error installing with Mac 10.9.3

I tried running gem install summarize but am getting the following error message:

Building native extensions.  This could take a while...
ERROR:  Error installing summarize:
    ERROR: Failed to build gem native extension.

    /Users/Dani/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling article.c
article.c:107:37: warning: passing 'const unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]
  if ((aWord == NULL) || (0==strlen(aWord)) ||(NULL==aLine)) return;
                                    ^~~~~
/usr/include/string.h:82:28: note: passing argument to parameter here
size_t   strlen(const char *);
                            ^
article.c:109:68: warning: passing 'const unsigned char *' to parameter of type 'const gchar *' (aka 'const char *') converts between pointers to integer types with different sign [-Wpointer-sign]
  aLine->words = g_list_append (aLine->words, (gpointer) g_strdup (aWord));
                                                                   ^~~~~
/usr/local/Cellar/glib/2.40.0_1/include/glib-2.0/glib/gstrfuncs.h:216:52: note: passing argument to parameter 'str' here
gchar*                g_strdup         (const gchar *str) G_GNUC_MALLOC;
                                                     ^
2 warnings generated.
compiling dictionary.c
dictionary.c:28:10: fatal error: 'libxml/xmlmemory.h' file not found
#include <libxml/xmlmemory.h>
         ^
1 error generated.
make: *** [dictionary.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/Dani/.rvm/gems/ruby-2.1.2/gems/summarize-1.0.3 for inspection.
Results logged to /Users/Dani/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/summarize-1.0.3/gem_make.out

Btw, I am running Ruby 2.1.2.
Thanks

Error when installing gem

Hello,
I'm trying to install gem on windows 8, with rails configured. When trying to install via bundler, I'm getting the following error:
$ gem install summarize
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing summarize:
ERROR: Failed to build gem native extension.

c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb

creating Makefile

make
generating summarize-i386-mingw32.def
compiling article.c
In file included from article.c:25:0:
libots.h:24:18: fatal error: glib.h: No such file or directory
compilation terminated.
make: *** [article.o] Error 1

Gem files will remain installed in c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/summarize-1.0.3 for inspection.
Results logged to c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/summarize-1.0.3/ext/summarize/gem_make.out

Any suggestions?

Thank you,
Sid

undefined method "summarize" in production

I have all the necessary packages installed for summarize, the gem is installed via my gemfile in my rails 3 application, and in development it seems to be working correctly however since deploying to production I am now getting an "undefined method 'summarize'"

Accessing keywords / about

More of a feature request rather than a bug.. But would be nice to get access to --about (since --keywords is deprecated), which simply returns the top keywords/topics for the input doc!

ex:

ots ig1 --about
Article talks about "concurrent,models,process,threads,channels"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.