模糊模块对我不起作用

时间:2016-05-23 08:38:02

标签: python ubuntu-14.04 spyder fuzzywuzzy

我遇到问题fuzzy module  因为当我尝试运行代码的第二部分时:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

         let storyboard = UIStoryboard(name: "Main", bundle: nil)

    let mainViewController = storyboard.instantiateViewControllerWithIdentifier("TabBarViewController") as! TabBarViewController
    let leftViewController = storyboard.instantiateViewControllerWithIdentifier("LeftMenuViewController") as! LeftMenuViewController
    let loginViewController = storyboard.instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController

    let nvc: UINavigationController = UINavigationController(rootViewController: loginViewController)
    leftViewController.mainVC = nvc
    let slideMenuController = SlideMenuController(mainViewController: nvc, leftMenuViewController: leftViewController)

    SlideMenuOptions.contentViewScale = 1
    SlideMenuOptions.hideStatusBar = false;

    self.window?.rootViewController = slideMenuController
    self.window?.makeKeyAndVisible()

    return true
}

它会出现如下错误:

fuzz.partial_ratio("this is a test", "this is a test!")

,当我尝试运行最后一部分时的第二个:

Traceback (most recent call last):

  File "<ipython-input-44-f5783c7c4393>", line 1, in <module>
    fuzz.partial_ratio("this is a test", "this is a test!")

  File "/usr/lib/python3/dist-packages/fuzzywuzzy/utils.py", line 23, in decorator
    return func(*args, **kwargs)

  File "/usr/lib/python3/dist-packages/fuzzywuzzy/utils.py", line 32, in decorator
    return func(*args, **kwargs)

  File "/usr/lib/python3/dist-packages/fuzzywuzzy/fuzz.py", line 69, in partial_ratio
    blocks = m.get_matching_blocks()

  File "/usr/lib/python3/dist-packages/fuzzywuzzy/StringMatcher.py", line 58, in get_matching_blocks
    self._str1, self._str2)

TypeError: inverse expected a list of edit operations

它会出现如下错误:

process.extractOne("cowboys", choices)

除了这两个代码之外,所有其他代码都运行良好。我该如何解决?我目前正在使用ubuntu 14.04LTS和Spyder来运行python。

编辑:我试图重新安装levenshtein,fuzzywuzzy和difflib模块。仍然出现同样的问题。是因为我正在使用ubuntu吗?因为当我尝试使用我的双启动窗口10运行时,它可以工作!

1 个答案:

答案 0 :(得分:0)

尝试卸载fuzzywuzyy和

 pip install fuzzywuzzy[speedup]

这个错误是由于旧版本的python-Levenshtein