小编sim*_*ley的帖子

nltk pos_tag用法

我试图在NLTK中使用语音标记并使用此命令:

>>> text = nltk.word_tokenize("And now for something completely different")

>>> nltk.pos_tag(text)

Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
nltk.pos_tag(text)
File "C:\Python27\lib\site-packages\nltk\tag\__init__.py", line 99, in pos_tag
tagger = load(_POS_TAGGER)
File "C:\Python27\lib\site-packages\nltk\data.py", line 605, in load
resource_val = pickle.load(_open(resource_url))
File "C:\Python27\lib\site-packages\nltk\data.py", line 686, in _open
return find(path).open()
File "C:\Python27\lib\site-packages\nltk\data.py", line 467, in find
raise LookupError(resource_not_found)
LookupError: 
**********************************************************************
Resource 'taggers/maxent_treebank_pos_tagger/english.pickle' not
found.  Please use the NLTK Downloader to obtain the resource:
Run Code Online (Sandbox Code Playgroud)

但是,我收到一条错误消息,显示:

engish.pickle not found.
Run Code Online (Sandbox Code Playgroud)

我已下载整个语料库,并且max.treebank_pos_tagger中有english.pickle文件.

我该怎么做才能让它发挥作用?

nltk pos-tagger

8
推荐指数
1
解决办法
8609
查看次数

主厨deploy_resource私有repo,ssh部署密钥和ssh_wrapper

我有很多麻烦让我的厨师食谱克隆私人回购.嗯,我昨天有工作但是在我的Vagrant盒子里'cheffin'六次之后,我已经打破了它.你可能猜到我是厨师新手.

在这里的deploy_resource指南之后,我创建了我的deploy.rb配方(缩短了):

deploy_branch "/var/www/html/ps" do
  repo              git@github.com:simonmorley/private-v2.git
  ssh_wrapper       "/tmp/.ssh/chef_ssh_deploy_wrapper.sh"
  branch            "rails4"
  migrate           false
  environment       "RAILS_ENV" => node[:ps][:rails_env] 
  purge_before_symlink %w{conf data log tmp public/system public/assets}
  create_dirs_before_symlink []
  symlinks(                        # the arrow is sort of reversed:
    "conf"   => "conf",            # current/conf          -> shared/conf
    "data"   => "data",            # current/data          -> shared/data
    "log"    => "log",             # current/log           -> shared/log
    "tmp"    => "tmp",             # current/tmp           -> shared/tmp
    "system" => "public/system",   # current/public/system -> shared/system
    "assets" => "public/assets"    # current/public/assets -> shared/assets
  )
  scm_provider Chef::Provider::Git # …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails chef-infra

7
推荐指数
1
解决办法
7122
查看次数

Bootstrap响应式日历3

我的网站使用Bootstrap 3作为GUI.由于Bootstrap首先是移动设备,我试图让整个网站也可以在智能手机上使用.但是我使用的是Fullcalendar,不幸的是,这在320px的设备宽度上无法使用 - 它太宽了.是否有针对该用例的响应式日历替代方案?

mobile fullcalendar responsive-design twitter-bootstrap-3

7
推荐指数
1
解决办法
1万
查看次数

使用Rails update_all方法更新具有另一列值的字段

我正在尝试使用update_all更新字段.但是我需要从另一个字段中获取值,该字段将重新写入我的特定格式.

如果我的模型中有这样的东西:

 def self.clean_mac_address()
   clean_mac_address = :macaddress.gsub(/[^0-9a-z]/i, '')
 end
Run Code Online (Sandbox Code Playgroud)

当我运行这个:

 Radacct.update_all("mac_clean = #{clean_mac_address}")
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:

 NoMethodError: undefined method `gsub' for :macaddress:Symbol
Run Code Online (Sandbox Code Playgroud)

有什么想法我怎么能这样做?或者有更简单的方法来更新该字段?

activerecord ruby-on-rails ruby-on-rails-3

6
推荐指数
1
解决办法
6119
查看次数

将 Google PubSub 与 Golang 结合使用。轮询服务的最有效(成本)方式

我们正在从 AMQP 迁移到 Google 的 Pubsub。

文档表明pull 可能是我们的最佳选择,因为我们使用的是计算引擎并且无法打开我们的工作人员以通过推送服务接收。

它还说拉动可能会产生额外的费用,具体取决于使用情况:

如果使用轮询,如果您频繁打开连接并立即关闭它们,可能会导致高网络使用率。

我们在 go 中创建了一个测试订阅者,它在循环中运行,如下所示:

func main() {
    jsonKey, err := ioutil.ReadFile("pubsub-key.json")
    if err != nil {
        log.Fatal(err)
    }
    conf, err := google.JWTConfigFromJSON(
        jsonKey,
        pubsub.ScopeCloudPlatform,
        pubsub.ScopePubSub,
    )
    if err != nil {
        log.Fatal(err)
    }
    ctx := cloud.NewContext("xxx", conf.Client(oauth2.NoContext))

    msgIDs, err := pubsub.Publish(ctx, "topic1", &pubsub.Message{
        Data: []byte("hello world"),
    })

    if err != nil {
        log.Println(err)
    }

    log.Printf("Published a message with a message id: %s\n", msgIDs[0])

    for {
        msgs, err := pubsub.Pull(ctx, "subscription1", …
Run Code Online (Sandbox Code Playgroud)

go google-compute-engine google-cloud-pubsub

5
推荐指数
1
解决办法
3816
查看次数

Rails - 为什么远程提交表单后jQuery无法加载

为了简单起见,我有一个更新部分的表单.没什么特别的.在部分内容中,我有一个jQuery可排序列表.在更新表单之前,我可以毫无问题地拖动列表中的内容.

但是,在我更新列表后,就像js没有被重新加载,我必须刷新整个页面才能让事情再次滚动.

我已经尝试了一切,甚至从Ryan Bates Esq借用了演示jQuery应用程序.在这里.在我将部分js shizzle放入部分后,这也无效.

我确定这很简单,但我是一个ajax/jQuery新手,我真的很挣扎.

视图:

#test_one
  = render "test_one"
Run Code Online (Sandbox Code Playgroud)

部分"test_one"

= form_for @location, :remote => true do |f|
  %table
    %tr= collection_select(:location, :type_ids, Type.all, :id, :name, {:prompt => true}, :multiple => true, :class=>"chzn-select")
     %tr
       %td
         %ul#types.unstyled{"data-update-url" => sort_types_locations_url}
           - @types.each do |type|
             = content_tag_for :li, type do
               %span.handle
                 [Drag]
               = type.name
Run Code Online (Sandbox Code Playgroud)

update.js.erb

$("#test_one").html('<%= escape_javascript render("test_two") %>');
Run Code Online (Sandbox Code Playgroud)

在我的控制器中:

  def update
    @location = Location.find(params[:id])
    @types = @location.types.order('location_types.position').limit(2)
    respond_to do |format|
      if @location.update_attributes!(params[:location])
        flash[:notice] = 'Settings …
Run Code Online (Sandbox Code Playgroud)

jquery coffeescript ujs ruby-on-rails-3

4
推荐指数
1
解决办法
1050
查看次数

无法使用npm和shell下载节点包

我使用msi安装程序在Windows 7上安装了Node 0.10.12

在此之前,我安装了python 2.7和gmake - 所有这些都安装成功.

现在,我正在打字

"$ sudo npm install -g sax" to download the sax package and nothing is happening. All I get is "...". Just 3 dots.
Run Code Online (Sandbox Code Playgroud)

这是否意味着下载正在进行或出现问题?我想有些事情是错的,因为我看到这些点30分钟仍然没有.我只是不明白.

另外,在我读到的关于node的书中,对于modules文件夹说"/ usr/local/lib/node_modules",但我在这里找到了默认模块"C:\ Program Files(x86)\nodejs \node_modules \npm \node_modules ".那是错的吗?这是否意味着安装出了问题?

node.js

4
推荐指数
1
解决办法
1万
查看次数

强制对象评估为假

我猜这可能是特定于应用程序的,但是我使用的是node.js-只要它在v8引擎中都能工作,我都不会介意。

我正在尝试创建一个Object计算结果为false的,例如:

var Foo = function() { return this; }
var bar = new Foo;
if (bar) // returns false;
Run Code Online (Sandbox Code Playgroud)

是否可以通过覆盖对象的某个功能来实现,例如toString

如果有人想知道它可能有什么用例:它是用于从通常返回布尔值但又可能遇到错误并返回我的自定义错误对象的函数中返回错误对象。

我希望以下任何条件句都可以充当该函数返回一个假值,而不必修改条件句以适应非布尔值的可能性。

javascript node.js

4
推荐指数
1
解决办法
502
查看次数

通过nodejs和websockets将openlayers中的功能保存到postgis

我试图通过websockets将矢量图层(openlayers)上创建的功能保存到postgreSQL 9.1/postGIS 2.0.我正在使用websockets,因为我正在插入表单数据以及几何体.

我的服务器是NodeJS 0.10.12和pg模块.

我正在尝试将要素的几何转换为字符串,将其从字母和括号中删除,并仅将数字发送到服务器.我在服务器端遇到有关几何的语法错误.

尽管尝试了很多东西和不同的语法,但我无法修复它.

客户端(代码段)

//create websockets
var so = new WebSocket("ws://localhost:8000");

//error report for websockets   
      so.onerror=function (evt) 
     {saveMSG.textContent = evt;}

//open websockets
 so.onopen = function(){
//get geometry      
 var jak=map.layers[2].features[0].geometry;
//make it a string      
 var as=new String(jak);
//keep the numbers      
 var hul=as.substring(11,as.length-1);
//make it WKT       
 var god=hul.toString();


//send it with stringify/websockets
       so.send(JSON.stringify({command: 'insertAll',
       geo: god,
//send other things from the form....
Run Code Online (Sandbox Code Playgroud)

和服务器端

var packet = JSON.parse(msg.utf8Data);
switch (packet['command']) 
{case 'insertAll':insertEm(packet['geo']) ;break;
//other cases here...call function according to …
Run Code Online (Sandbox Code Playgroud)

postgresql postgis openlayers websocket node.js

4
推荐指数
1
解决办法
1633
查看次数

在HappyBase中使用多个列过滤器

我正在使用HappyBase作为Python Thrift客户端连接到HBase.

我正在扫描表格,需要在多列上使用过滤器.如何在HappyBase中实现这一目标?Java使用Filterlist为此提供了一个选项.

python hbase multiple-columns

2
推荐指数
1
解决办法
4166
查看次数