首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用carrot2调整Lingo参数(用PHP)

用carrot2调整Lingo参数(用PHP)
EN

Stack Overflow用户
提问于 2021-07-26 17:46:30
回答 1查看 15关注 0票数 1

我正在尝试调整对Carrot2 REST API的调用:

代码语言:javascript
复制
        $client = new Client();
        try {
            $params = [
                'multipart'=> [
                    ['name'=> 'dcs.c2stream', 'contents' => $xml],
                    ['name' => 'dcs.algorithm', 'contents' => 'lingo'],
                    ['name' => 'dcs.output.format', 'contents' => 'JSON'],
                    ['name' => 'dcs.clusters.only', 'contents' => 'true'],
                    ['name' => 'MultilingualClustering.defaultLanguage', 'contents' => 'FRENCH'],
                    ['name' => 'preprocessing.labelFilters.minLengthLabelFilter.minLength', 'contents' => 5],
                    ['name' => 'preprocessing.documentAssigner.minClusterSize', 'contents' => 4]
                ],
                'debug' => false
            ];
$response = $client->request('POST', 'http://devbox:8080/dcs/rest', $params);

行话参数'preprocessing.labelFilters.minLengthLabelFilter.minLength‘和'preprocessing.documentAssigner.minClusterSize’在请求中没有影响。

我在lingo算法的文档中找到了它们。

感谢您的帮助!

EN

回答 1

Stack Overflow用户

发布于 2021-07-27 20:14:20

有了好的docker图像,一切都很好(docker pull touane/carrot2):

代码语言:javascript
复制
        $c2Payload = [
        'algorithm' => 'Lingo',
        'language' => 'French',
        'parameters' => [
            'preprocessing' => [
                'documentAssigner' => [
                    'minClusterSize' => 4
                ],
                'labelFilters' => [
                    'minLengthLabelFilter' => [
                        'minLength' => 8
                    ],
                    'completeLabelFilter' => [
                        'labelOverrideThreshold' =>  0.35
                    ]
                ]
            ],
            'scoreWeight' => 1, // Tri par score
            'clusterBuilder' => [
                'phraseLabelBoost' => 2.5
            ],
            'dictionaries' => [
                'wordFilters' => [
                    ['exact' => $this->getParameter('carrot2')['stop_words']]
                ]
            ],
            'matrixBuilder' => [
                'termWeighting' => [
                    '@type' => 'LinearTfIdfTermWeighting'
                ],
                'boostFields' => ['title']
            ]
        ],
        'documents' => []
    ];

            $client = new Client();
        $params = [
            'body' => json_encode($c2Payload ),
            'debug' => false
        ];
        $response = $client->request('POST', $this->getParameter('carrot2')['url'], $params);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68527709

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档