小编fel*_*zkn的帖子

NLTK - 如何使用NER

如何从NLTK调用NER以获取位于同一目录中的每个TXT文件的前200个字符的所有结果?


当我尝试这段代码时:

for filename in os.listdir(ebooksFolder):
    fname, fextension = os.path.splitext(filename)
        if (fextension == '.txt'):
            newName = 'ner_' + filename
            file = open(ebooksFolder + '\\' + filename)
            rawFile = file.read()
            partToUse = rawFile[:50]
            segmentedSentences = nltk.sent_tokenize(partToUse)
            tokenizedSentences = [nltk.word_tokenize(sent) for sent in segmentedSentences]
            posTaggedSentences = [nltk.pos_tag(sent) for sent in tokenizedSentences]
            nerResult = nltk.ne_chunk(posTaggedSentences)
            pathToCopy = 'C:\\Users\\Felipe\\Desktop\\books_txt\\'
            nameToSave = os.path.join(pathToCopy, newName + '.txt')
            newFile = open(nameToSave, 'w')
            newFile.write(nerResult)
            newFile.close()
Run Code Online (Sandbox Code Playgroud)

我收到这些错误:

Traceback (most recent call last):
  File …
Run Code Online (Sandbox Code Playgroud)

nltk python-2.7

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

Yii 2:使用模块声明为资产的图像

我在以下结构的模块中有一个图像:vendor/myvendorname/mymodulename/assets/img/delete-icon.png

我需要<img>通过JavaScript向页面添加一个,并且它可能具有src指向该属性的属性delete-icon.png.

$("#delete").attr("src", "?");
Run Code Online (Sandbox Code Playgroud)

如果将图像放入Yii创建的资产目录中,如何引用该图像?获得这条道路的方法是什么?

php yii-modules yii2

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

如果凭据错误,我可以禁用MS CRM 2011 SDK的登录提示吗?

现在我按如下方式访问CRM SDK

IServiceManagement<IDiscoveryService> serviceManagement =
                        ServiceConfigurationFactory.CreateManagement<IDiscoveryService>(discoveryUri);
ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = new System.Net.NetworkCredential(userName, password, domain);
using (DiscoveryServiceProxy serviceProxy = new DiscoveryServiceProxy(new DiscoveryServiceProxy(serviceManagement, credentials))
{
    RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();
    RetrieveOrganizationsResponse orgResponse =
                (RetrieveOrganizationsResponse)service.Execute(orgRequest);
    // do something with organisations
}
Run Code Online (Sandbox Code Playgroud)

但是,如果域凭据不正确,则会出现Windows登录提示(位于其中service.Execute).我不想要登录提示.我已经解决了这个问题,通过验证凭证,PrincipalContext然后再将它们传递给DiscoveryServiceProxy,但我对此并不完全满意.

有没有办法禁用登录提示?

c# wcf dynamics-crm-2011

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

Jena API - 使用listClasses()过滤要返回的类

public static void main(String[] args) {
    OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
    String fileName = "C:/Users/Felipe/Desktop/workspace/JenaTutorial/ontrdf.rdf";

    try {
        InputStream inputStream = new FileInputStream(fileName);
        model.read(inputStream, "RDF/XML");
        inputStream.close();
    } catch (Exception e) {
        System.out.println(e.getClass());
        System.out.println(e.getMessage());
    }

    ExtendedIterator<OntClass> it = model.listClasses();

    while (itI.hasNext()) {
        OntClass ontclass = it.next();
        System.out.println(ontclass.getLocalName());
    }
}
Run Code Online (Sandbox Code Playgroud)

我想仅列出我在本体上插入的真正的六个类(年份,出版商,语言,国家,书籍和作者).我不知道前六个意味着什么后面的那些线.有人知道如何过滤输出吗?

控制台显示:

Year
Publisher
Language
Country
Book
Author
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null …
Run Code Online (Sandbox Code Playgroud)

java rdf jena

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

CakePHP - 调用未定义的函数find()

我试图调用find()加载模型的函数,我得到以下错误:调用未定义函数find()

如果我可以打电话create()save(),为什么find()不确定?

public function admin_upload() {
        $this->layout = 'ajax';
        $this->loadModel('TempImage');

        $uploadedFileName = $_FILES['data']['name']['Staticpage']['main_image'];
        $uploadedType = $_FILES['data']['type']['Staticpage']['main_image'];
        $uploadedTmpFileName = $_FILES['data']['tmp_name']['Staticpage']['main_image'];
        $uploadedError = $_FILES['data']['error']['Staticpage']['main_image'];
        $uploadedSize = $_FILES['data']['size']['Staticpage']['main_image'];

        $this->TempImage->create();

        $imageData = array(
            'name' => $uploadedFileName,
            'type' => $uploadedType,
            'tmp_name' => $uploadedTmpFileName,
            'error' => $uploadedError,
            'size' => $uploadedSize
        );

        $temporaryData = array(
            'path' => $imageData
        );

        $this->TempImage->save($temporaryData);

        $lastTempImageThumbPath = $this->TempImage-find(
                'first',
                array(
                    'conditions' => array(
                        'id' => $this->TempImage->getLastInsertID()
                    )
                )
        );
        $this->set('thumb', $lastTempImageThumbPath['TempImage']['thumb_path']);
    }
Run Code Online (Sandbox Code Playgroud)

php cakephp

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

如何获取输入文件值而不是使用FormData

有人知道如何<input type="file">通过Ajax调用获得价值吗?

代替:

// more...

function uploadFile(event) {
        var file = event.target.files;
        event.stopPropagation();
        event.preventDefault();

        var data = new FormData();

        $.each(
            file,
            function(key, value) {
                data.append(key, value);
            }
        );

        $.ajax({
            url: 'site/upload',
            type: 'POST',
            data: data,
// more...
Run Code Online (Sandbox Code Playgroud)

uploadFile()被称为输入文件的变化.使用FormData对象的问题在于它在IE 10中不受支持.

html javascript ajax jquery

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

删除 woocommerce 购物车页面上的链接

我想删除产品名称上的链接,当单击购物车页面时该链接会重定向到产品页面。我尝试修改cart.php文件,但没有成功。我尝试修改这些行:

<td class="product-name">
<?php
    if (! $_product->is_visible())
        echo apply_filters('woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key);
    else
        echo apply_filters('woocommerce_cart_item_name', sprintf('<a href="%s">%s</a>', $_product->get_permalink(), $_product->get_title()), $cart_item, $cart_item_key);

    // Meta data
    echo WC()->cart->get_item_data($cart_item);

    // Backorder notification
    if ($_product->backorders_require_notification() && $_product->is_on_backorder($cart_item['quantity']))
        echo '<p class="backorder_notification">' . __('Available on backorder', 'woocommerce') . '</p>';
?>
</td>
Run Code Online (Sandbox Code Playgroud)

对此代码进行正确修改以删除产品名称上的链接是什么?

php woocommerce

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

标签 统计

php ×3

ajax ×1

c# ×1

cakephp ×1

dynamics-crm-2011 ×1

html ×1

java ×1

javascript ×1

jena ×1

jquery ×1

nltk ×1

python-2.7 ×1

rdf ×1

wcf ×1

woocommerce ×1

yii-modules ×1

yii2 ×1