Python综合图书馆

pyfathom的Python项目详细描述


比重瓶

python的文本理解库

示例

给定一组不同语法的输入字符串:

    '180g | 1 cup uncooked brown rice',
    '½ small butternut squash , cubed',
    '5½ tablespoons tahini (you can sub cashew butter)',
    'pecans 125g',
    'flat-leaf parsley a bunch, roughly chopped',
    'rocket 70g',
    'leftover marinade from the mushrooms',
    '15 oz (425 g) black beans, drained (reserve ¼ cup (60 ml) of the juice) and rinsed well',
    '1/4 teaspoon Garam Masala, for garnish',
    '2 tablespoons chopped cilantro, for garnish',

以及一组定义输入已知内容的“知识”规则,例如:

/\d+/ is number
number,/-|–/,number is range
/tbsp/ is unit
/cups?/ is unit
range|number,unit,/of/? is amount
amount,/\w+/+ is ,ingredient

pyfathom试图用类型名标记字符串的每个部分:

    '<amount><number>180</number><unit>g</unit><amount>|<amount><number>1</number><unit>cup</unit></amount><ingredient>uncooked brown rice</ingredient>',
    '<amount><number>½</number></amount><ingredient>small butternut squash</ingredient>,<ingredient>cubed</ingredient>',
    '<amount><number>5½<number><unit>tablespoons</unit></amount><ingredient>tahini</ingredient>(<ingredient>you can sub cashew butter</ingredient>)',
    '<ingredient>pecans</ingredient><amount><number>125</number><unit>g</unit></amount>',
    '<ingredient>flat-leaf parsley a bunch</ingredient>,<ingredient>roughly chopped</ingredient>',
    '<ingredient>rocket</ingredient><amount><number>70</number><unit>g</unit></amount>',
    '<ingredient>leftover marinade from the mushrooms</ingredient>',
    '<amount><number>15<number><unit>oz</unit></amount>(<amount><number>425</number><unit>g</unit></amount>)<ingredient>black beans</ingredient>,<ingredient>drained</ingredient>(<ingredient>reserve</ingredient><amount><number>¼</number><unit>cup</unit></amount>(<amount><number>60<number><unit>ml</unit></amount>)<ingredient>of the juice</ingredient>)<ingredient>and rinsed well</ingredient>',
    '<amount><number>1/4</number><unit>teaspoon</unit></amount><ingredient>Garam Masala</ingredient>,<ingredient>for garnish</ingredient>',
    '<amount><number>2<number><unit>tablespoons</unit></amount><ingredient>chopped cilantro</ingredient>,<ingredient>for garnish</ingredient>',

并且可以提取特定类型的零件,例如成分:

    'uncooked brown rice',
    'small butternut squash',
    'tahini',
    'pecans',
    'flat-leaf parsley a bunch',
    'rocket',
    'leftover marinade from the mushrooms',
    'black beans',
    'Garam Masala',
    'chopped cilantro',

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
javajaxb在嵌套节点中生成xmlns:xsi声明   java重定向到youtube以上传jsp上可用的视频   java提高了JVM和ANT的性能   java如何将返回的JSON数据放在HTML表单中   java如何发送XWWWFORMURLENCODE在重新授权   java为什么jvm XX:+EliminateAllocations失败   堆移除和重建方法?(爪哇)   Stanford NPL in Spark(Scala)应用程序运行到Java堆空间(Java.lang.OutOfMemoryError)   调试java中打开/关闭println的任何方式(详细模式)   java IntelliJ在鼠标悬停时显示JavaDocs工具提示   Olingo Odata Java中的自动扩展选项   json将postgres文本arry转换为java列表?   oop需要帮助推断Java代码   复选框的java添加操作侦听器AbstractTableModel   java如何从公共静态void main(String[]args)传递值   java从数据库中获取大值   java Processing 2.0电影从jar运行时无法打开电影文件   java如何在不使用应用程序的情况下刷新活动?   尝试将JSON解析为ListView时的Android:JSON parse:null对象引用