bugfix: extract numbered topic items within interest section#19
Open
RonghaiHe wants to merge 1 commit into
Open
bugfix: extract numbered topic items within interest section#19RonghaiHe wants to merge 1 commit into
RonghaiHe wants to merge 1 commit into
Conversation
…queries_from_description Co-Authored-By: OpenCode <opencode-agent[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the Semantic Scholar source query derivation to parse “interest” sections and numbered topic lists from a free-form research description.
Changes:
- Reworks
_derive_queries_from_descriptionto use a section-based state machine (in_interest_section) rather than per-line prefix stripping. - Extracts topics primarily from numbered items inside an “interest/关注/研究” section, with additional cleanup around common separators.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+64
to
+66
| in_interest_section = False | ||
|
|
||
| for line in desc.split("\n"): |
Comment on lines
+77
to
+80
| # Lines containing "interest" signal the start of the interest section | ||
| if re.search(r'\binterest', lower) or "关注" in lower or "研究" in lower: | ||
| in_interest_section = True | ||
| continue # header line itself is not a topic |
Comment on lines
+64
to
+66
| in_interest_section = False | ||
|
|
||
| for line in desc.split("\n"): |
Comment on lines
+82
to
+86
| # Within the interest section, extract from numbered items | ||
| if in_interest_section: | ||
| m = re.match(r'^\d+[\.\)\-:、]\s*(.*)', line) | ||
| if m: | ||
| content = m.group(1) |
Comment on lines
+91
to
94
| if content and len(content) > 1: | ||
| queries.append(content[:120]) | ||
|
|
||
| return queries or ["artificial intelligence"] |
| def _derive_queries_from_description(self) -> list[str]: | ||
| """Extract up to 3 search queries from the user description.""" | ||
| """Extract search queries from the user's research description.""" | ||
| import re |
| lower = line.lower() | ||
|
|
||
| # "not interested" signals the end of the interest section | ||
| if any(neg in lower for neg in ("not interested", "不感兴趣", "don't", "exclude")): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Similar to Pull Request: extract numbered topic items within interest section as queries of semantic scholar. The difference is that current version is based on the latest commit: 9aa7efb
Have tested via