-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created quick ParsCit lookup controller.
- Loading branch information
1 parent
6ea9298
commit 393b723
Showing
10 changed files
with
178 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Installation | ||
============ | ||
The installation is tested on a Macbook Pro running Mac OSX 10.6 Snowleopard. It | ||
will probably run on any *ix OS. | ||
|
||
Requirements | ||
------------ | ||
|
||
* [soap4r](http://dev.ctor.org/soap4r) | ||
|
||
Mac OSX 10.6 Installation | ||
------------------------- | ||
Bibmix application installation from remote git repository: | ||
|
||
$ git clone [email protected]:bwenneker/bibmix_app.git | ||
$ cd bibmix_app | ||
|
||
Then go to the bibmix plugin folder and retrieve the Bibmix submodules: | ||
|
||
$ cd vendor/plugins/bibmix | ||
$ git submodule init | ||
$ git submodule update | ||
|
||
|
||
|
||
Requirements installation | ||
------------------------- | ||
|
||
$ sudo gem install soap4r | ||
|
||
|
||
|
||
rake db:create:all | ||
rake db:test:prepare | ||
|
||
* * * | ||
Copyright (c) 2010 Bas Wenneker | ||
released under the MIT License |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2010 Bas Wenneker | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
require 'tempfile' | ||
require 'bibmix' | ||
|
||
class ParscitController < ApplicationController | ||
|
||
def show | ||
citation = params[:citation] | ||
|
||
@parscit_record_yaml = 'Please make a request.' | ||
@enhanced_record_yaml = '' | ||
if citation | ||
|
||
# First parse the citation with parscit. | ||
hash = parseWithParsCit(citation) | ||
@parscit_record_yaml = hash.to_yaml | ||
# Convert it to a Bibmix::Record so that it can be merged with data | ||
# from bibsonomy. | ||
record = Bibmix::Record.from_hash(hash) | ||
|
||
# Execute the mixing process. | ||
@enhanced_record = Bibmix::Bibsonomy::MixingProcess.new(record).execute | ||
|
||
@enhanced_record_yaml = @enhanced_record.to_yaml | ||
end | ||
|
||
respond_to do |format| | ||
format.html | ||
end | ||
end | ||
|
||
private | ||
def parseWithParsCit(str) | ||
if str.nil? || str.eql?("") | ||
raise 'Citation string is nil or empty' | ||
end | ||
|
||
parscit_dir = "/home/bas/Documents/parscit-100401" | ||
parscit_cmd = "#{parscit_dir}/bin/parseRefStrings.pl" | ||
|
||
# Convert the passed string to UTF-8, this prevents possible | ||
# seg faults in parseRefStrings.pl. | ||
ic = Iconv.new('UTF-8//IGNORE', 'UTF-8') | ||
valid_string = ic.iconv(str << ' ')[0..-2] | ||
|
||
# The ParsCit executable only reads from file so create a | ||
# temporary file an fill it with the citation string. | ||
tmp = Tempfile.new("parscit_parser_tmp") | ||
tmp.binmode | ||
tmp.puts(valid_string) | ||
tmp.close() | ||
|
||
xml = `perl "#{parscit_cmd}" "#{tmp.path()}"` | ||
hsh = Hash.from_xml(xml) | ||
|
||
citation = hsh['algorithm']['citationList']['citation'] | ||
|
||
tmp.unlink | ||
|
||
if citation.is_a?(Hash) | ||
citation | ||
elsif citation.is_a?(Array) && citation.length | ||
citation[0] | ||
else | ||
raise "Invalid citation datatype or no citations found (ln=#{citation.length})" | ||
end | ||
end | ||
|
||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ParscitHelper | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<ul> | ||
<li>Isaac G. Councill, C. Lee Giles, Min-Yen Kan. (2008) ParsCit: An open-source CRF reference string parsing package. To appear in the proceedings of the Language Resources and Evaluation Conference (LREC 08), Marrakesh, Morrocco, May.</li> | ||
</ul> | ||
|
||
<form action="" method="post"> | ||
<textarea id="citation" name="citation" style="width:600px;"><% #if(!@citation){ | ||
#puts "Isaac G. Councill, C. Lee Giles, Min-Yen Kan. (2008) ParsCit: An open-source CRF reference string parsing package. To appear in the proceedings of the Language Resources and Evaluation Conference (LREC 08), Marrakesh, Morrocco, May." | ||
#}else{ | ||
#puts @citation | ||
#} | ||
%></textarea><br /> | ||
<button>Go!</button> | ||
</form> | ||
|
||
<br /> | ||
|
||
<div> | ||
ParsCit: | ||
<pre><%=@parscit_record_yaml%></pre> | ||
Enhanced: | ||
<pre><%=@enhanced_record_yaml%></pre> | ||
</div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file is auto-generated from the current state of the database. Instead of editing this file, | ||
# please use the migrations feature of Active Record to incrementally modify your database, and | ||
# then regenerate this schema definition. | ||
# | ||
# Note that this schema.rb definition is the authoritative source for your database schema. If you need | ||
# to create the application database on another system, you should be using db:schema:load, not running | ||
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations | ||
# you'll amass, the slower it'll run and the greater likelihood for issues). | ||
# | ||
# It's strongly recommended to check this file into your version control system. | ||
|
||
ActiveRecord::Schema.define(:version => 0) do | ||
|
||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'test_helper' | ||
|
||
class ParscitControllerTest < ActionController::TestCase | ||
# Replace this with your real tests. | ||
test "the truth" do | ||
assert true | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'test_helper' | ||
|
||
class ParscitHelperTest < ActionView::TestCase | ||
end |
Submodule bibmix
updated
from b77c04 to ceb094