Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An open question of the ChatGPT generated code #20

Closed
Thompson-cyber opened this issue Oct 25, 2024 · 2 comments
Closed

An open question of the ChatGPT generated code #20

Thompson-cyber opened this issue Oct 25, 2024 · 2 comments

Comments

@Thompson-cyber
Copy link

Hi, I found that the code def infix_to_postfix was generated by ChatGPT, with the comment # these are from ChatGPT.

def infix_to_postfix(infix_expression):
precedence = {"+": 1, "-": 1, "*": 2, "/": 2, "^": 3}
postfix_stack = []
operator_stack = []
operand = ""
# Helper function to handle appending operands to the postfix stack
def append_operand(op):
if len(op) > 0:
postfix_stack.append(op)
for char in infix_expression:
if char == " ":
continue
if char.isdigit():
operand += char
else:
append_operand(operand)
operand = ""
if char == "(":
operator_stack.append(char)
elif char == ")":
while operator_stack and operator_stack[-1] != "(":
postfix_stack.append(operator_stack.pop())
if operator_stack:
operator_stack.pop() # Discard the '('
else:
while operator_stack and precedence.get(
operator_stack[-1], 0
) >= precedence.get(char, 0):
postfix_stack.append(operator_stack.pop())
operator_stack.append(char)
append_operand(operand)
# Append remaining operators from operator stack to postfix stack
while operator_stack:
postfix_stack.append(operator_stack.pop())
return postfix_stack

My question is whether there may be a license issue with this code. I noticed that this code is very similar to def calculate_expression in the laketree2/BOJ_pythonex repository.

  • The ChatGPT-generated code was updated in Jul 2024, while the similar code was updated in 2023.

  • def infix_to_postfix is protected by the AGPL-3.0 license. However, the similar code is under a No License license. According to the conditions of this No License license:

If you find software that doesn’t have a license, that generally means you have no permission from the creators of the software to use, modify, or share the software.

How do you view potential license conflicts between ChatGPT-generated code and existing open-source code?

If a license violation exists, would you add some explanation regarding the ChatGPT-generated code?

Thank you for your attention to this matter. 😊

@rf20008 rf20008 pinned this issue Nov 5, 2024
@rf20008
Copy link
Owner

rf20008 commented Nov 5, 2024

Thank you so much for pointing this out!

I didn't do my research when I asked ChatGPT to create this problem, and I promise to try my best to see if other similar code already exists that I can't use.

@Thompson-cyber
Copy link
Author

Thanks for your quickly reply. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants