小编Tha*_*ray的帖子

Stanford Parser和NLTK

是否可以在NLTK中使用Stanford Parser?(我不是在谈论斯坦福POS.)

python parsing nlp nltk stanford-nlp

89
推荐指数
8
解决办法
9万
查看次数

是否有任何Python IDE不需要管理员进行安装?

我们需要管理员来安装一些软件,它们需要将近一个月的时间才能为我们安装.所以我想找一些可以在没有管理员的情况下安装的Python IDE(Windows 7).有什么建议?

python

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

如何在窗口7上安装Beautiful Soup模块?

我在http://ricardianambivalence.com/2011/08/14/beautifulsoup-in-python-with-windows-7/找到了帖子

(我使用python 2.6并下载了beautifulsoup4-4.1.3)

运行"setup.py"后我找不到"BeautifulSoup.pyc"

有什么建议?

python beautifulsoup

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

Python:如何在单独的行中打印dict?

import re
sums = dict()
fh= open('wordcount.txt','r')
for line in fh:
    words = [word.lower() for word in re.findall(r'\b\w+\b', line)]
    for word in (words):
        if word in sums:
            sums[word] += 1
        else:
            sums[word] = 1
print sums
fh.close
Run Code Online (Sandbox Code Playgroud)

结果显示

{'and': 1, 'heart': 1, 'love': 2, 'is': 1, 'pass': 1, 'rest': 1, 'wounded': 1, 'at': 3, 
'in': 3, 'lie': 1, 'winchelsea': 1, 'there': 1, 'easy': 1, 'you': 2, 'body': 1, 'be': 
1, 'rise': 1, 'shall': 4, 'may': 2, 'sussex': 1, 'montparnasse': 1, …
Run Code Online (Sandbox Code Playgroud)

python dictionary

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

如何对文本文件中的单词进行排序?

在"test_wordss.txt"中

A
sentence
is
a
grammatical
unit
consisting
of
one
or
more
words
A
Run Code Online (Sandbox Code Playgroud)

我的代码:

for line2 in open('C://Users/Desktop/test_wordss.txt'):
    fields2 = line2.rstrip('\n').split('\t')
    print fields2.sort()
Run Code Online (Sandbox Code Playgroud)

我的代码的结果显示为无......

我做错什么了吗?有关在文本文件中排序单词的任何建议吗?

python

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

更换多个句号

在文件中:

Hello........girlllllllllll
W.o.W
Run Code Online (Sandbox Code Playgroud)

我试过:

for line in file.split('\n'):
    line = re.sub('[.]+', ' ', line)
    line = re.sub('[.]', '', line)
    print line
Run Code Online (Sandbox Code Playgroud)

结果显示:

 Hello girlllllllllll
 W o W
Run Code Online (Sandbox Code Playgroud)

是否有可能得到如下结果?

 Hello girlllllllllll
 WoW
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

python replace

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

带 ID 号的 Python Dict()

我是 dict() 的新手。我尝试使用defaultdict的示例。(Python 2.6)

from collections import defaultdict

s = 'happy sad happy cry crazy mad sad'

d = defaultdict(int)

for k in s.split():
    d[k] += 1

print d.items()
Run Code Online (Sandbox Code Playgroud)

结果:

[('crazy', 1), ('sad', 2), ('mad', 1), ('cry', 1), ('happy', 2)]
Run Code Online (Sandbox Code Playgroud)

我只是想知道这一点。有没有可能获取每个字典的ID?有什么建议吗?

预期结果:

[(1, 'crazy', 1), (2, 'sad', 2), (3, 'mad', 1), (4, 'cry', 1), (5, 'happy', 2)]
Run Code Online (Sandbox Code Playgroud)

python dictionary

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

Python:是否可以将句子分成两行?

Sentence = "the heart was made to be broken"
Run Code Online (Sandbox Code Playgroud)

如何使用Python分割句子以在单独的行中显示?(每行4个字)

Line1: the heart was made
Line2: to be broken
Run Code Online (Sandbox Code Playgroud)

有什么建议?

python

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

标签 统计

python ×8

dictionary ×2

beautifulsoup ×1

nlp ×1

nltk ×1

parsing ×1

replace ×1

stanford-nlp ×1