小编MMA*_*ASS的帖子

如何在 Python 中使用 Fuzzywuzzy 加速模糊匹配

我在 Python 中使用 Fuzzywuzzy 来匹配 2 个列表中的人名。但是,运行时间太长,因为一个列表包含 25000 个名称,另一个包含 39000 个名称。它已经运行了20个小时。

以前,我使用相同的代码来匹配具有 6000 和 3000 个名称的 2 个列表,运行时间为 1 小时。基于此,我当前工作的运行时间将需要 50 多个小时。

下面是我的代码:

names_array=[]
ratio_array=[]
def match_names(wrong_names,correct_names):
    for row in wrong_names:
        x=process.extractOne(row, correct_names, scorer=fuzz.token_set_ratio)
        names_array.append(x[0])
        ratio_array.append(x[1])
    return names_array,ratio_array

df=pd.read_csv("wrong-country-names.csv",encoding="ISO-8859-1")
wrong_names=df['name'].dropna().values

choices_df=pd.read_csv("country-names.csv",encoding="ISO-8859-1")
correct_names=choices_df['name'].values

name_match,ratio_match=match_names(wrong_names,correct_names)
Run Code Online (Sandbox Code Playgroud)

fuzz.token_set_ratio根据我拥有的数据选择作为得分手来执行这场多对多比赛。

下面是示例数据:

wrong_names = ['Alberto Steve', 'David Lee']
correct_names = ['Alberto Lee Steve', 'David Steve Lee'] 
Run Code Online (Sandbox Code Playgroud)

基本上,错误名称列表不包含中间名,为了忽略这一点并生成合理的匹配,我选择了fuzz.token_set_ratio.

通过在线研究,我找到了一个安装 python levenshtein 包的解决方案,以将运行时间加快 4-10 倍。但是,我的工作现在已经运行了 20 多个小时,我不想破坏当前的工作,所以我会在这之后尝试一下。

我想知道是否还有其他选择可以改善这一点。

提前致谢。

python runtime levenshtein-distance fuzzywuzzy

8
推荐指数
0
解决办法
1101
查看次数

如何从R Shiny中的数据表中删除第一列(索引)

我想知道是否有办法从 Shiny 的数据表中删除索引列(第一列)。

例如,名称列之前的 (1, 2, 3)列如下面的屏幕截图所示:

在此处输入图片说明

下面是我的代码:

header <- dashboardHeader(
  title = "Test"
)

sidebar <- dashboardSidebar(
)

body <- dashboardBody(
            box(title = "Test", width = 7, status = "warning", DT::dataTableOutput("df"))
)

# UI
ui <- dashboardPage(header, sidebar, body)

# Server
server <- function(input, output, session) {

  output$df = DT::renderDataTable(df, options = list(
    autoWidth = TRUE,
    columnDefs = list(list(width = '10px', targets = c(1,3)))))
    }

# Shiny dashboard
shiny::shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)

提前致谢。

html css r shiny dt

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

Graphileon 是只为 Neo4j 还是所有图数据库设计的?

我想知道 Graphileon 是仅为 Neo4j 还是所有图形数据库设计的?

Graphileon 在其网站上没有专门提及除 Neo4j 之外的图数据库。然而,从我观看的所有教程来看,他们使用 Neo4j 作为底层图形数据库。

提前致谢。

graphics graph neo4j graph-databases graphileon

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

R Shiny Dashboard DataTable 列宽

我正在构建一个 Shiny 仪表板,仪表板上的一个面板是 DataTable。

下面是我的代码:

  output$table = DT::renderDataTable(b1, selection = 'single')
Run Code Online (Sandbox Code Playgroud)

数据表中的列宽现在根据列名的宽度进行调整。但是,某些单元格值是文本,并且这些文本被压缩以显示在多行中,因为它们比列名称长。

我想知道是否有办法调整列宽以适应一行中的单元格值。

或者,有没有办法为列设置固定宽度并通过悬停来获取单元格值的全部内容?

提前致谢。

javascript r shiny shinydashboard dt

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