小编Ash*_*ngh的帖子

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
查看次数

使用CUDA并行处理将彩色图像转换为灰度图像

我试图解决一个问题,我应该将彩色图像更改为灰度图像.为此我使用CUDA并行方法.

我在GPU上调用的kerne代码如下.

__global__
void rgba_to_greyscale(const uchar4* const rgbaImage,
                   unsigned char* const greyImage,
                   int numRows, int numCols)
{
    int absolute_image_position_x = blockIdx.x;  
    int absolute_image_position_y = blockIdx.y;

  if ( absolute_image_position_x >= numCols ||
   absolute_image_position_y >= numRows )
 {
     return;
 }
uchar4 rgba = rgbaImage[absolute_image_position_x + absolute_image_position_y];
float channelSum = .299f * rgba.x + .587f * rgba.y + .114f * rgba.z;
greyImage[absolute_image_position_x + absolute_image_position_y] = channelSum;

}

void your_rgba_to_greyscale(const uchar4 * const h_rgbaImage,
                            uchar4 * const d_rgbaImage,
                            unsigned char* const d_greyImage,
                            size_t numRows, …
Run Code Online (Sandbox Code Playgroud)

parallel-processing cuda gpu image-processing

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

Angular2反应形式确认了价值的平等

我正在尝试创建一个Angular2 Reactive表单,我必须确认用户输入的电子邮件地址.这是一个链接到plunker

import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { User } from './signup.interface';

@Component({
selector: 'signup-form',
template: `
    <form novalidate (ngSubmit)="onSubmit(user)" [formGroup]="user">
    <label>
        <span>Full name</span>
        <input type="text" placeholder="Your full name" formControlName="name">
    </label>
    <div class="error" *ngIf="user.get('name').touched && user.get('name').hasError('required')">
        Name is required
    </div>
    <div class="error" *ngIf="user.get('name').touched && user.get('name').hasError('minlength')">
        Minimum of 2 characters
    </div>
    <div formGroupName="account">
        <label>
        <span>Email address</span>
        <input type="email" placeholder="Your email address" formControlName="email">
        </label>
        <div
        class="error"
        *ngIf="user.get('account').get('email').hasError('required') && user.get('account').get('email').touched">
        Email …
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular2-forms angular

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

Highcharts x-axis tick以偏移量开始

我试图删除offset的嘀嗒声x-axis.

我想第一跳10/8从一开始就x-axisy-axis交集.

10-8 应该在两个标签之间的标记上.

我在highchart中有以下代码.

xAxis: {
            categories: categories,
            title: {
              text: title_x_axis,
              style: {
                fontWeight: 'bold'
              },
              formatter: function(){
                return "<h3><b>" + this.value + "</b></h3>";  
              }
            },
            min: 0,
            startOnTick: true,
            endOnTick: true,
            minPadding: 0,
            maxPadding: 0,
            align: "left"               
        },
Run Code Online (Sandbox Code Playgroud)

Max padding和min padding设置为0,所以我不知道问题是什么?

编辑:

我创造了一个我正在处理的图表类型的小提琴.注意下面的图像有不同的x轴值,因为我没有使用相同的小提琴值.tickmarkPlacement: "on"我拍摄快照后也设置了.我希望Jan标签从行的开头开始.它目前有一些抵消.

Highchart x轴偏移

谁能帮我这个?

javascript highcharts

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

有很多通过铁路的关系

我正在使用facebook api从fb中获取用户.

我想将用户存储在我的模型中 User

我正在使用has many through与商店用户的关系

我的user模型中有用户模型关系.

has_many :friends, :through => :user_friends, :class_name => "User", :foreign_key => "friend_id"
Run Code Online (Sandbox Code Playgroud)

User friends 模型中间表以获取用户的朋友.

belongs_to :user
belongs_to :user, :foreign_key => "friend_id"
Run Code Online (Sandbox Code Playgroud)

用户朋友user_idfriend_id我在迁移中添加了列.

.friends在用户对象上使用时出错.

ActiveRecord::HasManyThroughAssociationNotFoundError: Could not find the association :user_friends in model User
Run Code Online (Sandbox Code Playgroud)

有人能帮忙吗?提前致谢.

ruby-on-rails associations has-many model-associations

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