Azure / aml-deploy

GitHub Action that allows you to deploy machine learning models in Azure Machine Learning.
MIT License
41 stars 18 forks source link

Uncomplete sentence in patterns #52

Closed Mochahintwain closed 3 years ago

Mochahintwain commented 3 years ago

@marvinbuss the syntax {"IS_SENT_START": False, "OP": "*"} works only for words that come before the word in the pattern right? what about the sentences where we can't make any assumptions about how the sentence will end but still want to match as soon as the sentence starts with a certain set of words. One example: "I thought I share our newest features with you" Now the Words we match is "I thought" and "our". Now do I need to add something to make sure it matches even though there are words coming after the words in pattern3?

` def _you_centered21( self, rule_id="R0061", description="Put your recipient in the center of your sentence. Simply replace the I focused sentence with a You focused one.That's how you catch their attention.", info="Try to be very precise on what you want and use the present form if possible.", example_pos="You can find a guide on how you can benefit from the most recent product update attached.", example_neg="I thought I share our newest features with you" ) -> None: """ Check for negative and positive tone.

    rule_id (str): The ID of the rule.
    description (str): The description of the rule.
    info (str): Additional info about the rule.
    example_pos (str): Positive example for this rule.
    example_neg (str): Negative example for this rule.
    """
    # Define matcher
    matcher = Matcher(self.nlp.vocab)

    # Define patterns to match
    pattern1 = [
        {"LOWER": "I"}
    ]

    pattern2 = [
        {"LOWER": "thought"}
    ]

    pattern3 = [
        {"LOWER": "our"} ,{"IS_SENT_START": False, "OP": "*"}
    ]

    # Add the patterns to the matcher and apply the matcher to the doc
    matcher.add("positivetone_pattern", [pattern1, pattern2, pattern3])
    matches = matcher(self.doc)

    # Merge the matched intervals
    intervals = [(start, end) for match_id, start, end in matches]
    merged = merge_intervals(intervals)

    # Add recommendations
    if len(merged) > 0:
        self._add_recommendation(
            rule_id=rule_id,
            description=description,
            info=info,
            example_pos=example_pos,
            example_neg=example_neg,
            token_intervals=merged
        )`
marvinbuss commented 3 years ago

@Mochahintwain Can you please add this to the correct repository? This was opened in an Azure repository.

The first pattern will not work since "I" is not lowercase.

If you want to match "I thought ..." you have to use the following pattern:

pattern = [
  {"LOWER": "i", "IS_SENT_START": True},
  {"LOWER": "thought"}
]

In the third pattern, the "IS_SENT_START": False is not really helping here. It will match on any word "our" in any sentence no matter what is follwed by this word.

Mochahintwain commented 3 years ago

Thanks for noticing....I looked up how to change the repository but can't find it...only found it for project boards but we don't have a board. How does that work?

And what do I have to write in the pattern to match for "I thought I share our newest features with you" and ANY other sentence that includes I THOUGHT and the word OUR?